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.
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.