getservent

Name

getservent -- get service entry

Synopsis

#include <netdb.h>

struct servent *getservent(void);

Description

getservent reads the next line from the file /etc/services and returns a structure servent containing the broken out fields from the line. The /etc/services file is opened if necessary.

The servent structure is defined in netdb.h as follows:
  struct servent {
              char  *s_name;      /* official service name */
              char  **s_aliases;  /* alias list */
              int   s_port;       /* port number */
              char  *s_proto;     /* protocol to use */
  }

Return Value

getservent returns the servent structure, or a NULL pointer if an error occurs or the end of the file is reached.

Files

/etc/services services database file