.TH getprotoent() "" "" "Sockets Function (libsocket)"
.PC "Get protocol entry"
.B "#include <netdb.h>"
\fBstruct protoent *getprotoent(\|);\fR
.PP
.B getprotoent()
reads the next entry from file
.BR /etc/protocols ,
which holds information about all protocols recognized by
your local network.
If necessary, it opens the file.
It 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
To close
.BR /etc/protocols ,
call function
.BR endprotoent() .
.PP
.B getprotoent()
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 "getprotobynumber()," getprobnu
.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.
