getnetent(3N)getnetent(3N)NAMEgetnetent(), getnetbyaddr(), getnetbyname(), setnetent(), endnetent()-
get, set, or end network entry
and each return a pointer to a structure of type netent containing the
broken-out fields of a line in the network data base,
The members of this structure are:
The official name of the network.
A null-terminated list of alternate names for the network.
The type of the network number returned; always
The network 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 net‐
work data base is not closed after each
call to (either directly or indirectly
through one of the other calls).
Closes the file.
Sequentially searches from the beginning of the file until a
(among either the official names or the
aliases) matching its parameter name is
found, or until EOF is encountered.
Sequentially searches from the beginning of the file
until a network number matching its param‐
eter net is found, or until EOF is encoun‐
tered. The parameter net must be in net‐
work order. The parameter type must be
the constant Network numbers are supplied
in host order (see byteorder(3N)).
If the system is running Network Information Service (NFS), and obtain
their network information from the NIS server (see ypserv(1M) and
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. If multiple threads interleave calls to the
threads will enumerate disjoint subsets of the network database.
Name Service Switch-Based Operation
The library routines and internally call the name service switch to
access the "networks" database lookup policy 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 network names
and return a null pointer (0) on EOF or when they are unable to open
also returns a null pointer if its type parameter is invalid.
The following code excerpt counts the number of network entries:
int count = 0;
while (netbuf=getnetent() != NULL)
The above reentrant interfaces have been moved from to They are
included to support existing applications and may be removed in the
future release. New multithreaded applications should not use these
The reentrant interfaces function the same as the regular interfaces
(those without the suffix.) However, and expect to be passed the
address of a struct netent and will store the address of the result at
the supplied parameter. An additional parameter, the address of struct
netent_data, which is defined in the file cannot be a NULL pointer.
and return a −1 if the operation is unsuccessful. A 0 is returned oth‐
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), networks(4), ypfiles(4), nsswitch.conf(4),