.TH getnetent() "" "" "Sockets Function"
.PC "Fetch a network entry"
.B "#include <netdb.h>"
\fBstruct netent *getnetent(\|);\fR
.PP
.B getnetent()
fetches a network entry.
It reads the next line of file
.BR /etc/network ,
which describes all entities on your local network;
if necessary, it opens this file.
.PP
.B getnetent()
returns a pointer to an object of type
.BR netend ,
which is defined in header file
.BR <netdb.h> :
.PP
.DM
struct netent {
	char *n_name;	/* official name of net */
	char **n_aliases;	/* alias list */
	int n_addrtype;	/* net number type */
	unsigned long n_net;	/* net number */
};
.DE
.PP
The following describes the members:
.IP \fBn_name\fR
The official name of the network.
.IP \fBn_aliases\fR
This points to a zero-terminated list of alternate names for the network.
.IP \fBn_addrtype\fR
The type of the network number returned; currently, only type
.B AF_INET
is recognized.
.IP \fBn_net\fR
The network's number.
Network numbers are returned in the machine's byte order.
.PP
.B getnetent()
returns a pointer to the
.B netent
structure it built.
It returns NULL if something went wrong or if it has reached the end of
.BR /etc/networks .
You must call function
.B endnetent()
to close
.BR /etc/networks .
.SH "See Also"
.Xr "getnetbyaddr()," getnetbya
.Xr "getnetbyname()," getnetbyn
.Xr "endnetent()," endnetent
.Xr "libsocket," libsocket
.Xr "netdb.h," netdb.h
.Xr "setnetent()" setnetent
