The getprotobynumber() call returns a pointer to the ETC\PROTOCOL file entry specified by a protocol number.
Syntax
#include <netdb.h> struct protoent * getprotobynumber(proto) int proto;
Parameters
proto
Description
This call searches the ETC\PROTOCOL file for the specified protocol number.
The getprotobynumber() call retrieves the protocol information from the ETC\PROTOCOL file using the specified proto parameter as a search key. An application program can use this call to access a protocol name, its aliases, and protocol number.
The getprotobynumber() call searches the file sequentially from the start of the file until it encounters a matching protocol number, or until it reaches the end of the file.
The getprotobynumber() call returns a pointer to a protoent structure, which contains fields for a line of information in the ETC\PROTOCOL file. The protoent structure is defined in the <NETDB.H> file.
Use the endprotoent() call to close the ETC\PROTOCOL file.
Return Values
The getprotobynumber() call returns a pointer to a protoent structure for the network protocol specified on the call. The return value points to static data that subsequent API calls can modify. A pointer to a protoent structure indicates success. A NULL pointer indicates an error or EOF.
The protoent structure is defined in the <NETDB.H> header file and contains the following elements:
Element
Related Calls