The getprotoent() function reads the next line from the file /etc/protocols and returns a structure protoent containing the broken out fields from the line. The /etc/protocols file is opened if necessary.
The protoent structure is defined in <netdb.h> as follows:
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
int p_proto; /* protocol number */
The getprotoent() function returns the protoent structure, or a NULL pointer if an error occurs or the end of the file is reached.