TCP/IP Programming Manual

Errors
If an error occurs, lwres_getipnodebyname and lwres_getipnodebyaddr set *error_ptr
to an appropriate error code, and the function returns a NULL pointer. The error codes and their
meanings are 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 address pointed to by hp, which is already in network order, can be used directly in a
sockaddr_in or sockaddr_in6 structure, as in the following example:
struct sockaddr_in sin;
struct hostent *hp;
if ((hp = lwres_getipnodebyname (nameptr, AF_INET, AI_PASSIVE,
&error_num)) != (struct hostent *) NULL) {
memmove ((char *)&sin.sin_addr.s_addr, (char *)hp -> h_addr,
(size_t) hp -> h_length );
Usage Guidelines
The lwres_getipnodebyname function searches host entries sequentially until a match with
the name argument occurs.
The lwres_getipnodebyname function returns a pointer to a structure of type hostent
whose members specify data obtained from a Name Server.
The hostent structure is statically declared. Subsequent calls to lwres_gethostbyname
replace the existing data in the hostent structure.
lwres_getipnodebyname provides the same functionality as lwres_gethostbyname,
but is protocol-independent.
lwres_getnameinfo
The lwres_getnameinfo function translates a protocol-independent host address to a hostname.
This function uses a socket address to search for a hostname and service name. Given a binary
IPv4 or IPv6 address and a port number, this function returns the corresponding hostname and
service name from a name0resolution service. (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>
int lwres_getnameinfo(const struct sockaddr *sa, socklen_t
salen, char
* host, socklen_t hostlen,char *serv, socklen_t servlen, int flags);
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
error := lwres_getnameinfo( sa, salen, host, hostlen, serv, servlen,
flags);
150 Library Routines