HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
g
getprotoent(3N) getprotoent(3N)
NAME
getprotoent(), getprotobynumber(), getprotobyname(), setprotoent(), endprotoent() - get protocol 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);
MULTITHREAD USAGE
Thread Safe: Yes
Cancel Safe: Yes
Async-cancel Safe: No
Async-signal Safe: No
These functions can be called safely in a multithreaded environment. They may be cancellation points in
that they call functions that are cancel points.
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 official 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 proto-
col 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 protocol 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 struct protoent 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 pro-
perty shared by all threads. setprotoent() may be used in a multithreaded application, but resets the
enumeration position for all threads. getprotoent() enumerates protocol entries: successive 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) services or Network Information Service
Plus (NIS+) services,
getprotobyname()
and getprotobynumber() get the protocol information
from the NIS server (see ypserv(1M) and ypfiles(4)) or NIS+ server (see nis+(1)), respectively.
HP-UX Release 11i: December 2000 − 1 − Section 3−−329
___
___