|
|
#include <netdb.h>struct protoent *getprotoent(void);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobynumber(int proto);
void setprotoent(int stayopen);
void endprotoent(void);
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:
getprotoent reads the next line of the database, opening it if necessary.
setprotoent opens and rewinds the database. 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 database.
getprotobyname and getprotobynumber sequentially search from the beginning of the database until a matching protocol name or protocol number is found, or until an EOF is encountered.
Functions that provide successive entries in files on successive calls must be called from a single thread.
Only the Internet protocols are currently understood.
These functions use the name-to-address resolution mechanism described in netdir(3N) and netconfig(4bnu). This mechanism may use a local database or the services of Network Information Service (NIS) or Domain Name Service (DNS).