getprotoent(3N)getprotoent(3N)NAMEgetprotoent(), getprotobynumber(), getprotobyname(), setprotoent(),
endprotoent() - get, set, or end protocol entry
The and functions each return a pointer to a structure of type protoent
containing the broken-out fields of a line in the network protocol data
The members of this structure are:
The official name of the protocol.
A null-terminated list of alternate names for the protocol.
The protocol number.
Functions behave as follows:
Reads the next line of the file, opening the file if necessary.
Opens and rewinds the file.
If the stayopen flag is non-zero, the proto‐
col data base is not closed after each call
to (either directly or indirectly through
one of the other calls).
Closes the file.
Each sequentially searches from the beginning of the file until
protocol name (among either the official
names or the aliases) or protocol number is
found, or until EOF is encountered.
In a multithreaded application, and use thread-specific storage that is
re-used in each call. The return value should be unique for each
thread and should be saved, if desired, before the thread makes the
For enumeration in multithreaded applications, the position within the
enumeration is a process-wide property shared by all threads. may be
used in a multithreaded application, but resets the enumeration posi‐
tion for all threads. enumerates protocol entries: successive calls to
will return either successive protocol entries or NULL. If multiple
threads interleave calls to the threads will enumerate disjoint subsets
of the protocol database.
If the system is running the Network Information Service (NIS), and get
the protocol information from the NIS server (see ypserv(1M) and
Name Service Switch-Based Operation
The library routines and their reentrant counterparts, internally call
the name service switch to access the "protocols" database lookup pol‐
icy configured in the 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.
and return a null pointer (0) on EOF or when they are unable to open
The above reentrant interfaces have been moved from to They are
included to support existing applications and may be removed in a
future release. New multithreaded applications should use the regular
The reentrant interfaces performs the same operation as their regular
counterpart (those without the suffix.) However, and expect to be
passed the address of a parameter and will store the address of the
result at this supplied parameter. An additional parameter, an address
to struct protoent_data, which is defined in the file cannot be a NULL
The reentrant routines return if the operation is unsuccessful, or, in
the case of if the end of the services list has been reached. is
The following code excerpt counts the number of protocols entries:
Programs that use the interfaces described in this manpage cannot be
linked statically because the implementations of these functions employ
dynamic loading and linking of shared objects at run time.
was developed by Sun Microsystems Inc.
FILESSEE ALSOypserv(1M), nsswitch.conf(4), protocols(4), ypfiles(4),