HPlogo HP-UX IPv6 Porting Guide: HP-UX 11i v2 September 2004 > Chapter 7  Function Calls Converting IP addresses to Names

getnameinfo(3N)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

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.

  • NI_NUMERICSERV: If set, getnameinfo() returns only service’s port number.

  • NI_NUMERICSCOPE: If set, getnameinfo() returns the numeric form of the scope-ID. It is ignored if the sa parameter is not an IPv6 address.

  • NI_DGRAM: If set, service is a datagram service (SOCK_DGRAM). Default: service is a stream service (SOCK_STREAM). This distinguishes between services for TCP and UDP that share port numbers (for example, 512 to 514).

© 2004 Hewlett-Packard Development Company, L.P.