TCP/IP Programming Manual

host_entry_ptr = gethostbyname (host_name_ptr);
host_entry_ptr = host_file_gethostbyname (host_name_ptr);
struct hostent *host_entry_ptr;
char *host_name_ptr;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
host_entry_ptr := gethostbyname (host_name_ptr);
host_entry_ptr := host_file_gethostbyname (host_name_ptr);
INT(32) host_entry_ptr;
STRING .EXT host_name_ptr;
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 111).
host_name_ptr
input value; points to either the official name or an alias of the host whose Internet address is
to be found.
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
The specified hostname is valid, but the host does not have an IP address.NO_ADDRESS
Usage Guidelines
The gethostbyname() function is used for resolving names with hosts file. You can choose
host file, external dns server, or a combination of host file and external dns server to resolve
the host name.
The parameters passed to the gethostbyname and host_file_gethostbyname functions
are case-sensitive.
The hostent structure is statically declared. Subsequent calls to gethostbyname or
host_file_gethostbyname replace the existing data in the hostent structure.
NOTE: The function host_file_gethostbyname() supports only local hosts file.
Example
The address pointed to by host_entry_ptr, which is already in network order, can be used
directly in a sockaddr_in structure, as in the following example:
gethostbyname, host_file_gethostbyname 111