GETSERVENT [ Berkeley Sockets/iX Reference Manual ] MPE/iX 5.0 Documentation
Berkeley Sockets/iX Reference Manual
GETSERVENT
C Interface
#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 getservent, getservbyname, and getservbyport subroutines each return
a pointer to an object with the following structure containing the
broken-out fields of a line in the network services database,
/etc/services.
struct servent {
char *s_name; /* official name of service */
char **s_aliases; /* alias list */
long s_port; /* port service resides at */
char *s_proto; /* protocol to use */
};
The members of this structure are as follows:
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. Port
numbers are returned in network byte order.
s_proto The name of the protocol to use when contacting the
service.
The getservent subroutine reads the next line of the file, opening the
file if necessary.
The setservent subroutine opens and rewinds the file. If the stayopen
flag is non-zero, the services database is not closed after each call to
getservent (either directly or indirectly through one of the other
getserv calls).
The endservent subroutine closes the file.
The getservbyname and getservbyport subroutines sequentially search from
the beginning of the file until a service name (among either the official
names or the aliases) matching the parameter name or a port number
matching the parameter port 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.
Restrictions
All information is contained in a static area, so it must be copied if it
is to be saved.
Return Value
The getservent, getservbyname, and getservbyport subroutines return a
null pointer (0) on EOF or when they are unable to open SERVICES.NET.SYS.
MPE/iX Specific
The name of the services file on MPE/iX is SERVICES.NET.SYS, as opposed
to /etc/services on HP-UX.
Author
UCB (University of California at Berkeley)
Files
SERVICES.NET.SYS
See Also
services
MPE/iX 5.0 Documentation