getservbyname

Name

getservbyname -- get service entry

Synopsis

#include <netdb.h>

struct servent *getservbyname(const char *name, const char *proto);

Description

The getservbyname() function returns a servent structure for the line from /etc/services that matches the service name using protocol proto.

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

getservbyname() 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