TCP/IP Programming Manual
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.
addr
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 inet_addr function.)
len
input value; the length of the Internet address pointed to by host_addr_ptr.
type
input value; the type of address specified: either AF_INET (IPv4) or AF_INET6 (IPv6).
Errors
lwres_gethostbyaddr 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_gethostbyaddr by passing the Internet address 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.
char *addr;
int len, type;
struct hostent *hp;
hp = lwres_gethostbyaddr(addr, len, type);
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.
lwres_gethostbyname
The lwres_gethostbyname function gets the Internet address (IPv4) 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_gethostbyname(name);
TAL Synopsis
lwres_gethostbyname 145