TCP/IP Programming Manual
proto
input value; the Internet protocol number of the protocol.
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 protoent structure is statically declared. Subsequent calls to getprotobynumber
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) by specifying its number:
#include <netdb.h>
...
struct protoent *proto;
...
if ((proto = getprotobynumber(1)) == NULL) {
fprintf(stderr, "Proto 1: unknown protocol\n");
exit (1);
}
/* Call succeeded. Information about icmp is in
* the proto structure.
*/
getservbyname
The getservbyname function gets the port number associated with the specified service.
C Synopsis
#include <netdb.h>
serv_entry_ptr = getservbyname (serv_name_ptr, proto_ptr);
struct servent *serv_entry_ptr;
char *serv_name_ptr, *proto_ptr;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
serv_entry_ptr := getservbyname (serv_name_ptr, proto_ptr);
INT(32) serv_entry_ptr;
STRING .EXT serv_name_ptr,
.EXT proto_ptr;
serv_entry_ptr
return value; points to a structure (based on the servent structure) that contains information
on the specified service. This is the return value.
If the lookup fails, NULL is returned.
serv_name_ptr
input value; points to a null-terminated character string that contains the service name.
124 Library Routines