Gets a protocol entry from the /etc/protocols file by number.
Standard C Library (libc.a)
#include <netdb.h> int getprotobynumber_r(proto, protoent, proto_data) register int proto; struct protoent *protoent; struct protoent_data *proto_data;
The getprotobynumber_r subroutine retrieves protocol information from the /etc/protocols file using a specified protocol number as a search key.
An application program can use the getprotobynumber_r subroutine to access a protocol name, aliases, and number.
The getprotobynumber_r subroutine searches the /etc/protocols file sequentially from the start of the file until it finds a matching protocol name, protocol number, or until it reaches the end of the file.
The subroutine writes the protoent structure, which contains fields for a line of information in the /etc/protocols file.
The netdb.h file defines the protoent structure.
The getprotobynumber subroutine overwrites static data returned in subsequent calls. The getprotobynumber_r subroutine does not.
Use the endprotoent_r subroutine to close the /etc/protocols file.
proto | Specifies the protocol number. |
protoent | Points to the protoent structure. |
proto_data | Points to the proto_data structure. |
The function returns a 0 if successful and a -1 if unsuccessful.
/etc/protocols | Contains protocol information. |
endprotoent_r Subroutine, getprotobyname_r Subroutine, getprotoent_r Subroutine, and setprotoent_r Subroutine.