TCP/IP Programming Manual

TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
host_entry_ptr := lwres_gethostbyname2(name, af);
INT(32) host_entry_ptr;
STRING .EXT name;
INT af;
host_entry_ptr
return value; points to a structure (based on the hostent structure) in which information about
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 lwres_h_errno
is set as indicated below under Errors.
name
input value; points to either the official name or an alias of the host whose Internet address is
to be found.
af
input value; an integer that sets the address type searched for by the function and returned by
the function. af is either AF_INET (IPv4) or AF_INET6 (IPv6).
Errors
lwres_gethostbyname2 returns NULL to indicate an error. In this case, the global variable
lwres_h_errno contains one of the following error codes as defined in netdb.h:
The host or address was not found.HOST_NOT_FOUND
A recoverable error occurred, for example, a timeout. Retrying the lookup may succeed.TRY_AGAIN
A non-recoverable error occurred.NO_RECOVERY
The name exists, but has no address information associated with it (or for a reverse lookup,
the address information exists but has no name associated with it). The code NO_ADDRESS
is accepted as a synonym for NO_DATA for backwards compatibility.
NO_DATA
lwres_hstrerror (page 152) translates these error codes into readable error messages.
Example
The example makes a call to lwres_gethostbyaddr2 by passing the hostname and address
family as arguments. If an answer is found, a pointer to the hostent structure is returned and
stored in hp. NULL is returned if no answer is found.
int af;
char *name;
struct hostent *hp;
hp = lwres_gethostbyname2(name, af);
Usage Guidelines
The parameter name passed to the lwres_gethostbyname2 function is case-sensitive.
The hostent structure is statically declared. Subsequent calls to lwres_gethostbyname2
replace the existing data in the hostent structure.
lwres_getipnodebyaddr
The lwres_getipnodebyaddr function searches host entries until a match with src is found.
The lwres_getipnodebyaddr function returns a pointer to a hostent struct whose members
lwres_getipnodebyaddr 147