.TH getnetbyname() "" "" "Sockets Function (libsocket)"
.PC "Get a network entry by address"
.B "#include <netdb.h>"
\fBstruct netent *getnetbyname(\fIname\^\fB)\fR
\fBchar *\fIname\^\fB;\fR
.PP
.B getnetbyname()
fetches a network entry.
It opens and searches file
.BR /etc/networks ,
which describes all entities on your local network,
for the entry with
.IR name .
.B /etc/networks
must have been opened by function
.BR setnetent() .
.PP
.B getnetbyname()
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 cannot find an entry with
.IR address .
.SH "See Also"
.Xr "endnetent()," endnetent
.Xr "getnetent()," getnetent
.Xr "getnetbyaddr()," getnetbya
.Xr "libsocket," libsocket
.Xr "netdb.h," netdb.h
.Xr "setnetent()" setnetent
