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

getaddrinfo(3N)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

getaddrinfo() is a nodename-to-address and servicename-to-port-number function call. The protocol-independent function call complies with POSIX 1003.1g Draft 6.6 (1997). For more information refer to the getaddrinfo(3N) man page.

Syntax

getaddrinfo(const char *nodename, const char *servname, const struct 
addrinfo *hints, struct addrinfo **res);

Parameters

*nodename: A pointer to a node name or numeric string, such as an IPv4 dotted-decimal address or an IPv6 hexadecimal address. nodename can also point to a NULL string.

servname: A pointer to a service name (such as ftp) or port number (such as 21). *servname can also point to a NULL string. Either *nodename or *servname must point to a name or numeric string.

*hints: A pointer to an addrinfo structure containing filters for socket-type, address family, or protocol-type. hints can also point to a NULL string. addrinfo and hints are described below.

**res: A pointer to a linked list of addrinfo structures each containing a socket address and information regarding the socket.

addrinfo Data Structure pointed-to by hints

struct addrinfo {     int     ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST,
* See RFC 2533 for more details*/
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for nodename */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
NOTE: Initialize the entire addrinfo data structure to zero before assigning hint values to ai_flags, ai_family, ai_socktype, or ai_protocol.
© 2004 Hewlett-Packard Development Company, L.P.