getservent() — Get the next service entry
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <netdb.h>
struct servent *getservent(void);
#define _OE_SOCKETS
#include <netdb.h>
struct servent *getservent(void);
General description
The getservent() call reads the next line of the /etc/services or the tcpip.ETC.SERVICES data set.
The getservent() call returns a pointer to the next entry in the /etc/services or the tcpip.ETC.SERVICES data set.
getservbyname(), getservbyport(), and getservent() all use the same static area to return the servent structure. This static area is only valid until the next one of these functions is called on the same thread.
- Element
- Description
- s_aliases
- An array, terminated with a NULL pointer, of alternative names for the service.
- s_name
- The official name of the service.
- s_port
- The port number of the service.
- s_proto
- The protocol required to contact the service.
Special behavior for C++: To use this function with C++, you must use the _XOPEN_SOURCE_EXTENDED 1 feature test macro.
Returned value
The return value points to data that is overwritten by subsequent calls returning the same data structure.
If successful, getservent() returns a pointer to a servent structure.
If unsuccessful or End Of File (EOF), getservent() returns a NULL pointer.