getprotoent(3N) getprotoent(3N)
NAME
getprotoent, getprotobynumber, getprotobyname, setprotoent,
endprotoent - get protocol entry
SYNOPSIS
cc [options] file -lsocket -lnsl
#include <netdb.h>
struct protoent *getprotoent(void);
struct protoent *getprotobyname(char *name);
struct protoent *getprotobynumber(int proto);
int setprotoent(int stayopen);
int endprotoent(void);
DESCRIPTION
getprotoent, getprotobyname, and getprotobynumber each return
a pointer to an object with the following structure containing
the broken-out fields of a line in the network protocol data
base, /etc/protocols.
The protoent structure include the following members:
char *p_name; /* official name of protocol */
char **p_aliases; /* alias list */
int p_proto; /* protocol number */
The members of this structure are:
p_name the official name of the protocol
p_aliases a zero terminated list of alternate names
for the protocol
p_proto the protocol number
getprotoent reads the next line of the file, opening the file
if necessary.
setprotoent opens and rewinds the file. If the stayopen flag
is non-zero, the net data base will not be closed after each
call to getprotoent (either directly, or indirectly through
one of the other getproto calls).
endprotoent closes the file.
Copyright 1994 Novell, Inc. Page 1
getprotoent(3N) getprotoent(3N)
getprotobyname and getprotobynumber sequentially search from
the beginning of the file until a matching protocol name or
protocol number is found, or until an EOF is encountered.
Files
/etc/protocols
/var/yp/{domainname}/protocols.byname
/var/yp/{domainname}/protocols.bynumber
Return Values
A NULL pointer is returned on an EOF or error.
REFERENCES
protocols(4), ypserv(1M)
NOTICES
All information is contained in a static area so it must be
copied if it is to be saved. For multi-threaded applications,
this must be done on a per-thread basis.
Functions that provide successive entries in files on
successive calls must be called from a single thread.
Only the Internet protocols are currently understood.
The Network Information Service (NIS) will be used to obtain
protocol entires when its installed and running. Otherwise,
entries will be read from /etc/protocols.
Copyright 1994 Novell, Inc. Page 2