GETSERVENT(3N) — Series 300 and 800 Only
NAME
getservent, getservbyport, getservbyname, setservent, endservent − get service entry
SYNOPSIS
#include <netdb.h>
struct servent *getservent()
struct servent *getservbyname(name, proto)
char *name, *proto;
struct servent *getservbyport(port, proto)
int port; char *proto;
setservent(stayopen)
int stayopen;
endservent()
DESCRIPTION
Getservent, getservbyname, and getservbyport each return a pointer to a structure of type servent containing the broken-out fields of a line in the network services data base, /etc/services.
The members of this structure are:
s_name The official name of the service.
s_aliases A null-terminated list of alternate names for the service.
s_port The port number at which the service resides.
s_proto The name of the protocol to use when contacting the service.
Getservent reads the next line of the file, opening the file if necessary.
Setservent opens and rewinds the file. If the stayopen flag is non-zero, the services data base will not be closed after each call to getservent (either directly or indirectly through one of the other “getserv” calls).
Endservent closes the file.
Getservbyname and getservbyport sequentially search from the beginning of the file until a matching service name (among either the official names or the aliases) or port number is found, or until EOF is encountered. If a non-NULL protocol name is also supplied (for example "tcp" or "udp"), searches must also match the protocol.
If the system is running Yellow Pages (NFS), getservbyname gets the service information from the YP server. See ypserv(1M) and ypfiles(4).
RETURN VALUE
Getservent, getservbyname and getservbyport return a null pointer (0) on EOF or when they are unable to open /etc/services.
WARNINGS
All information is contained in a static area so it must be copied if it is to be saved.
DEPENDENCIES
Implemented on the Series 300 and 800 only.
AUTHOR
UCB (University of California at Berkeley)
FILES
/etc/services
SEE ALSO
ypserv(1M), services(4), ypfiles(4).
INTERNATIONAL SUPPORT
8-bit data, messages.
Hewlett-Packard Company — May 11, 2021