GETSERVENT(3n,L) AIX Technical Reference GETSERVENT(3n,L)
-------------------------------------------------------------------------------
getservent, getservbyname, getservbyport, setservent, endservent
PURPOSE
Gets service entry.
LIBRARY
Internet Library (libc.a)
SYNTAX
#include <netdb.h>
struct servent *getservent ( ) void setservent (stayopen)
int stayopen;
struct servent *getservbyname (name, proto)
char *name, *proto; void endservent ( )
struct servent *getservbyport (port, proto)
int port;
char *proto;
DESCRIPTION
The getservent, getservbyname, and getservbyport subroutines each return a
pointer to an object. This object is a servent structure, which contains the
field of a line in the /etc/services file (the network services data base).
The servent structure is defined in the netdb.h header file, and it contains
the following members:
char *s_name; /* official name of service */
char **s_aliases; /* alias list */
long s_port; /* port where service resides */
char *s_proto; /* protocol to use */
The members of the structure are defined below:
s_name Official name of the service.
s_aliases
An array, terminated by a 0, of alternate names for the service.
Processed November 7, 1990 GETSERVENT(3n,L) 1
GETSERVENT(3n,L) AIX Technical Reference GETSERVENT(3n,L)
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. If the file is not
open, getservent opens it.
The setservent subroutine opens and rewinds the file. If the stayopen
parameter is 0, the service data base is closed after each call to
getservbyname or getservbyport. Otherwise, the file is not closed after each
call.
The endservent subroutine closes the file.
The getservbyname and getservbyport subroutines search the file sequentially
from its beginning until finding a matching protocol name or port number, or
until encountering the end of the file. When a protocol name is also supplied,
searches also match the protocol.
RETURN VALUE
A pointer to a servent structure is returned on success.
Note: The return value points to static data that is overwritten by subsequent
calls.
A NULL pointer (0) is returned if an error occurs or the end of the file is
reached.
FILE
/etc/services
Service name data base.
RELATED INFORMATION
In this book: "getprotoent, getprotobynumber, getprotobyname, setprotoent,
endprotoent."
The discussion of /etc/services in AIX TCP/IP User's Guide.
Processed November 7, 1990 GETSERVENT(3n,L) 2