TCP/IP Programming Manual

?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
host_entry_ptr := gethostbyaddr (host_addr_ptr, length,
addr_type);
host_entry_ptr := host_file_gethostbyaddr (host_addr_ptr,
length, addr_type);
INT(32) host_entry_ptr;
STRING .EXT host_addr_ptr;
INT(32) length,
addr_type;
host_entry_ptr
return value; points to a structure (based on the hostent structure) in which information on the
specified host is returned. The information includes the official name, aliases, and addresses
for the host.
If the lookup fails, NULL is returned and the external variable h_errno is set as indicated in
Errors (page 110).
host_addr_ptr
input value; points to the Internet address of the host whose name is to be found. The address
pointed to is in binary format and network order. (This address is in the same format and order
as the return value of the function inet_addr (page 134).)
length
input value; the length of the Internet address pointed to by host_addr_ptr.
addr_type
input value; the type of address specified. Its value must be AF_INET.
Errors
If an error occurs, the external variable h_errno is set to one of the following values:
The specified host was not found. This is the only possible value if the resolver code has
been disabled.
HOST_NOT_FOUND
The local server did not receive a response from an authoritative server. Try again later.TRY_AGAIN
An error has occurred from which there is no recovery.NO_RECOVERY
Usage Guidelines
The address that is returned in host_entry_ptr can be used directly in a sockaddr_in
structure. The address is in network order.
The gethostbyaddr and host_file_gethostbyaddr library routines are for INET use only.
For IPv6, use the getnameinfo or library routines (see getnameinfo (page 117)).
gethostbyname, host_file_gethostbyname
The gethostbyname and host_file_gethostbyname functions get the Internet address of
the host whose name is specified. These functions are for INET applications only; for
protocol-independent applications, see getaddrinfo (page 107) or getipnodebyname (page 116).
Although these two functions provide the same service, they accomplish the service in different
ways. To determine which function best suits your purpose, see the Usage Guidelines (page 111).
C Synopsis
#include <socket.h>
#include <netdb.h>
110 Library Routines