GETSERVENT(3N) COMMAND REFERENCE GETSERVENT(3N)
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
The calls getservent, getservbyname, and getservbyport each
return a pointer to an object with the following structure
containing the broken-out fields of a line in the network
services data base, /etc/services.
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port # */
char *s_proto; /* protocol to use */
};
The members of this structure are:
s_name The official name of the service.
s_aliases
A zero terminated list of alternate names for
the service.
s_port The port number at which the service resides.
Port numbers are returned in network byte
order.
s_proto The name of the protocol to use when contacting
the service.
The getservent call reads the next line of the file, opening
the file /etc/services if necessary; the file remains open
upon completion.
Printed 5/12/88 1
GETSERVENT(3N) COMMAND REFERENCE GETSERVENT(3N)
If the Yellow Pages aren't running, both getservbyname and
getservbyport open the /etc/services file, if necessary,
then sequentially search from the beginning of the file
until a matching protocol name or port number is found, or
until EOF is encountered. If a protocol name is also
supplied (non-NULL), searches must also match the protocol.
The /etc/services file is closed upon completion. Port
numbers are supplied in network byte order.
The call setservent opens and rewinds the file. If the
stayopen flag is nonzero, the service data base will not be
closed by subsequent calls to endservent (either directly,
or indirectly through one of the other getserv calls);
endservent closes the file.
FILES
/etc/services
/etc/yp/domainname/hosts.byname
/etc/yp/domainname/hosts.byaddr
The domainname is the name of your host (domain).
DIAGNOSTICS
Null pointer (0) returned on EOF or error.
CAVEATS
All information is contained in a static area so it must be
copied if it is to be saved.
SEE ALSO
getprotoent(3n), services(5n), and ypserv(8).
Printed 5/12/88 2
%%index%%
na:408,141;
sy:549,2364;
de:2913,1772;5165,1524;
fi:6689,352;
di:7041,171;
ca:7212,178;
se:7390,211;
%%index%%000000000134