newbee pl help netdb.h

can anyone pl help me.

i am trying to use geetservbyname function,
which is in the netdb.h
the netdb.h has been included in the c code.

but during compiling, the compiler complains:

undefined reference to ‘getservbyname’

this happens for other functions which are in netdb.h

can someone pl help me

gcc -o foo foo.o -lsocket

The -lsocket is key - it brings in the socket library.