Open System Services Library Calls Reference Manual (G06.27+, H06.04+)

OSS Library Calls (i - m) lwres_getnameinfo(3)
NI_NUMERICSERV
Species to return the numeric port number instead of the ser-
vice name.
NI_DGRAM Species to return only ports congured for a UDP service. This
ag is required for ports that use different services for UDP and
TCP.
DESCRIPTION
This function uses a socket address to search for a host name and service name. Given a binary
IPv4 or IPv6 address and port number, this function returns the corresponding hostname and ser-
vice name from a name resolution service. By default, this function returns the host names fully
qualied domain name.
This function provides the same information as the getnameinfo() function but uses the Domain
Name System (DNS) lightweight resolver server lwresd instead of the named DNS server.
NOTES
This function, along with the lwres_getipnodebyaddr( )
function, is a protocol-independent
replacement for the lwres_gethostbyaddr() function. lwres_getnameinfo() provides extra
functionality beyond what lwres_getipnodebyaddr( ) provides because it handles both the hosts
address and port number.
RETURN VALUES
Upon successful completion, this function returns 0 (zero) and the requested values are stored in
the buffers specied for the call. Otherwise, the value returned is -1.
ERRORS
errno is set to indicate the error when the error is EAI_SYSTEM.
EXAMPLE
The following example calls the lwres_getnameinfo() function to get a host names fully
qualied domain name:
error = lwres_getnameinfo((struct sockaddr *)sin,
addrlen, hname, sizeof(hname), sname,
sizeof(sname), NI_NUMERICHOST|NI_NUMERICSERV);
if(error)
ifprintf(stderr, "Error: %s0, lwres_gai_strerror(error));
RELATED INFORMATION
Functions: getnameinfo(3), lwres_gai_strerror(3).
527187-004 Hewlett-Packard Company 4111