.TH getprotobyname() "" "" "Sockets Function (libsocket)"
.PC "Get protocol entry by protocol name"
.B "#include <netdb.h>"
\fBstruct protoent *getprotobyname(\fIname\^\fB);\fR
\fBchar *\fIname\^\fB;\fR
.PP
.B getprotobyname()
searches file
.BR /etc/protocols ,
which holds information about all protocols recognized by
your local network, for the protocol named
.IR name .
.B /etc/protocols
has to have been opened by a call to
.BR setprotoent() .
.PP
.B getprotobyname()
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 getprotobyname()
returns NULL if an error occurs, or if it encounters the end of the file.
.SH "See Also"
.Xr "endprotoent()," endprotoe
.Xr "getprotobynumber()," getprobnu
.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.
