HP-UX IPv6 Porting Guide (February 2007)

Function Calls Converting IP addresses to Names
getnameinfo(3N)
Chapter 7 35
getnameinfo(3N)
The getnameinfo() function takes a socket-address structure and returns a node name or
service name.
Header Files
#include <sys/socket.h>
#include <netdb.h>
Syntax
int getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen, char *serv, size_t servlen, int flags);
The getnameinfo() function translates a socket address to a node name and service location.
The definitions for getaddrinfo() apply to getnameinfo().
Parameters
*sa
: A pointer to a socket-address structure awaiting translation.
sockelen_t
: The integer size of the socket address structure pointed to by
sa
.
*host
: A pointer to the host name returned by getnameinfo().If the function finds no host
name, it returns the host’s IP address If
host
points to NULL or
hostlen
equals zero, then
host
does not return a host name or IP address. Both
host
and
serv
cannot point to NULL.
hostlen
: The length of the character string
host
.
*serv
: A pointer to the service name returned by getnameinfo(). If it finds no service name,
it returns the service’s port number. If
serv
points to NULL or
servlen
equals zero, then
serv
does not return a service name or port number.
servlen
: The length of the character string
serv
.
flags
:
flags
change the default actions of the function.
NI_NOFQDN: If set, getnameinfo() returns only the host name of Fully Qualified Domain
Name (FQDN).
NI_NUMERICHOST: If set, getnameinfo() returns only the numeric form of host’s address.
NI_NAMEREQD: If set, getnameinfo() returns an error if it finds no host name.