Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (i - m) lwres_getnameinfo(3)
NI_NUMERICSERV
Specifies to return the numeric port number instead of the ser-
vice name.
NI_DGRAM Specifies to return only ports configured for a UDP service. This
flag 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 name’s fully
qualified 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.
EXAMPLE
The following example calls the lwres_getnameinfo( ) function to get a host name’s fully
qualified 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));
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 host’s
address and port number.
RETURN VALUES
Upon successful completion, this function returns 0 (zero) and the requested values are stored in
the buffers specified for the call. Otherwise, the value returned is -1.
ERRORS
errno is set to indicate the error when the error is EAI_SYSTEM.
RELATED INFORMATION
Functions: getnameinfo(3), lwres_gai_strerror(3).
527187-017 Hewlett-Packard Company 4169