getprotoent.3n (2010 09)

g
getprotoent(3N) getprotoent(3N)
NAME
getprotoent(), getprotobynumber(), getprotobyname(), setprotoent(), endprotoent() - get, set, or end proto-
col entry
SYNOPSIS
#include <netdb.h>
struct protoent *getprotoent(void);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobynumber(int proto);
int setprotoent(int stayopen);
int endprotoent(void);
_XOPEN_SOURCE_EXTENDED only
void setprotoent(int stayopen);
void endprotoent(void);
DESCRIPTION
The getprotoent(), getprotobyname()
, and getprotobynumber()
functions each return a
pointer to a structure of type protoent containing the broken-out fields of a line in the network protocol
data base,
/etc/protocols.
The members of this structure are:
p_name The ofcial name of the protocol.
p_aliases A null-terminated list of alternate names for the protocol.
p_proto The protocol number.
Functions behave as follows:
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 protocol data
base is not closed after each call to getprotoent()
(either directly or
indirectly through one of the other
getproto* calls).
endprotoent() Closes the file.
getprotobyname(),
getprotobynumber()
Each sequentially searches from the beginning of the file until a matching pro-
tocol name (among either the official names or the aliases) or protocol number
is found, or until EOF is encountered.
In a multithreaded application,
getprotoent(), getprotobyaddr(), and getprotobyname()
use thread-specific storage that is re-used in each call. The return value structprotoent should be
unique for each thread and should be saved, if desired, before the thread makes the next getproto*()
call.
For enumeration in multithreaded applications, the position within the enumeration is a process-wide
property shared by all threads.
setprotoent() may be used in a multithreaded application, but
resets the enumeration position for all threads. getprotoent() enumerates protocol entries: succes-
sive calls to getprotoent() will return either successive protocol entries or NULL. If multiple
threads interleave calls to getprotoent(), the threads will enumerate disjoint subsets of the protocol
database.
If the system is running the Network Information Service (NIS),
getprotobyname() and getproto-
bynumber() get the protocol information from the NIS server (see ypserv (1M) and ypfiles (4)).
Name Service Switch-Based Operation
The library routines
getprotobyname(), getprotobynumber(), getprotoent(), and their
reentrant counterparts, internally call the name service switch to access the "protocols" database lookup
policy configured in the /etc/nsswitch.conf file (see nsswitch.conf(4)). The lookup policy defines
the order and the criteria of the supported name services used to resolve protocol names and numbers.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)