Gets services file entry.
Standard C Library (libc.a)
#include <netdb.h> int getservent_r(servent, serv_data) struct servent *servent; struct servent_data *serv_data;
The getservent_r subroutine opens and reads the next line of the /etc/services file.An application program can use the getservent_r subroutine to retrieve information about network services and the protocol ports they use.
The /etc/services file remains open after a call by the getservent_r subroutine. To close the /etc/services file after each call, use the setservent_r subroutine. Otherwise, use the endservent_r subroutine to close the /etc/services file.
servent | Points to the servent structure. |
serv_data | Points to the serv_data structure. |
The getservent_r fails when a successful match occurs. Thegetservent subroutine overwrites static data returned on subsequent calls. The getservent_r subroutine does not.
/etc/services | Contains service names. |
endservent_r Subroutine, setservent_r Subroutine, getservbyport_r Subroutine, and getservbyname_r Subroutine.