GETPROTOENT(3N)
NAME
getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent − get protocol entry
USAGE
#include <netdb.h>
struct protoent *getprotoent()
struct protoent *getprotobyname(name) char *name;
struct protoent *getprotobynumber(proto) int proto;
setprotoent(stayopen) int stayopen
endprotoent()
DESCRIPTION
Getprotoent, getprotobyname, and getprotobynumber each return a pointer to an object with the following structure, which contains the fields of a line in the network protocol database, /etc/protocols. struct protoent { char *p_name; /* official name of protocol */ char **p_aliases; /* alias list */ long 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 database will not close after each call to getprotoent (either directly or indirectly through one of the other “getproto” calls).
Endprotoent closes the file.
Getprotobyname and getprotobynumber search sequentially, from the beginning of the file, until a matching protocol name or number is found or until EOF is encountered.
NOTES
All information is kept in a static area, so you must copy it if you wish to save it. These functions only understand the Internet protocol (IP).
DIAGNOSTICS
Null pointer (zero) returned on EOF or error.
FILES
/etc/protocols database of available protocols