.TH getprotobynumber() "" "" "Sockets Function (libsocket)"
.PC "Get protocol entry by protocol number"
.B "#include <netdb.h>"
\fBstruct protoent *getprotobynumber(\fIprotocol\^\fB);\fR
\fBint \fIprotocol\^\fB;\fR
.PP
.B getprotobynumber()
searches file
.BR /etc/protocols ,
which holds information about all protocols recognized by
your local network, for the protocol identified by
.IR number .
.B /etc/protocols
has to have been opened by a call to
.BR setprotoent() .
.PP
.B getprotobynumber()
returns a pointer to an object of type
.BR protoent ,
which is defined in header file
.BR netdb.h :
.DM
struct protoent {
	char *p_name;	/* official name of protocol */
	char **p_aliases;	/* alias list */
	int p_proto;	/* protocol number */
};
.DE
.PP
The following details each member:
.IP \fBp_name\fR
The official name of the protocol.
.IP \fBp_aliases\fR
This points to a zero-terminated list of alternate names for the protocol.
.IP \fBp_proto\fR
The number of the protocol.
.PP
.B getprotobynumber()
returns NULL if an error occurs, or if it encounters the end of the file.
.SH "See Also"
.Xr "endprotoent()," endprotoe
.Xr "getprotobyname()," getprobna
.Xr "getprotoent()," getprotoe
.Xr "libsocket," libsocket
.Xr "netdb.h," netdb.h
.Xr "setprotoent()" setprotoe
.SH Notes
This function uses a static data space.
If your application needs to save these data it must copy them
before any subsequent calls overwrite them.
.PP
At present, only the Internet protocols are understood.
