TCP/IP Programming Manual

proto_name_ptr
input value; points to a null-terminated character string that contains the protocol name.
Errors
No errors are returned for this function.
Usage Guidelines
This call requires the presence of a PROTOCOL file providing information on the available
protocols. The information in the default PROTOCOL file is given in Appendix A (page 241).
The format of this file is described in the TCP/IPv6 Configuration and Management Manual.
The parameters passed to the getprotobyname function are case-sensitive.
The protoent structure is statically declared. Subsequent calls to getprotobyname replace
the existing data in the protoent structure.
Example
The following programming example makes a call to get information on the ICMP protocol (identified
as icmp in the PROTOCOL file):
#include <netdb.h>
...
struct protoent *proto;
...
if ((proto = getprotobyname("icmp")) == NULL) {
fprintf(stderr, "icmp: unknown protocol\n");
exit (1);
}
/* Call succeeded. Information about icmp is in
* the proto structure.
*/
getprotobynumber
The getprotobynumber function gets the protocol name of the protocol with the specified number.
C Synopsis
#include <netdb.h>
proto_entry_ptr = getprotobynumber (proto);
struct protoent *proto_entry_ptr;
int proto;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
proto_entry_ptr := getprotobynumber (proto);
INT(32) proto_entry_ptr;
INT proto;
proto_entry_ptr
return value; points to a structure (based on the protoent structure) that contains all the
information available about the specified protocol. This is the return value.
If the lookup fails, NULL is returned.
getprotobynumber 123