TCP/IP Programming Manual

?NOLIST,SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
host_entry_ptr := lwres_gethostbyname(name);
INT(32) host_entry_ptr;
STRING .EXT name;
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.
Errors
lwres_gethostbyname 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
char *name;
struct hostent *hp;
hp = lwres_gethostbyname(name);
The above example makes a call to lwres_gethostbyname by passing the hostname as an
argument. 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.
Usage Guidelines
The parameter name passed to the lwres_gethostbyname function is case-sensitive.
The hostent structure is statically declared. Subsequent calls to lwres_gethostbyname
replace the existing data in the hostent structure.
lwres_gethostbyname2
The lwres_gethostbyname2 function gets the Internet address (IPv4 or IPv6) of the host whose
name is specified. (This function is supported for G06.27 and later G-series RVUs and H06.05
and later H-series RVUs of NonStop TCP/IPv6.)
C Synopsis
#include <netdb.h>
host_entry_ptr = lwres_gethostbyname2(name, af);
146 Library Routines