Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
OSS Library Calls (g - h) getaddrinfo(3)
int ai_protocol; /* 0 or IPPROTO_xxx */
size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* a pointer to the
canonical name for nodename */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
Each addrinfo struct contains the following members:
ai_family A literal of the form PF_xxx, where xxx indicates the address family as a proto-
col family name
ai_socktype A literal of the form SOCK_xxx, where xxx indicates the socket type
ai_protocol Either 0 (zero) or a literal of the form IPPROTO_xxx, where xxx indicates the
protocol type
These members can be used with the socket() function. The literals have the values described in
the socket(2) reference page.
Each addrinfo struct also contains a member named ai_addr that can be used with any socket
function that requires a socket address. The length of a specific ai_addr value is described by
the member named ai_addrlen.
The value of the ai_flags member of an addrinfo structure can be set before being passed with
the hints parameter or tested after return of the structure as part of the list of addrinfo structs.
ai_flags can be one or more of the following as a logically ORed value:
AI_ADDRCONFIG
Requests the return of only IPv6 records if a host has at least one IPv6 source
address configured, or of only IPv4 records if a host has at least one IPv4 source
address configured.
AI_ALL Requests the return of all matching IPv4 and IPv6 records. This flag is ignored
unless AI_V4MAPPED is also set.
AI_CANONNAME
Requests the return of the canonical name for the host if hostname is not NULL.
AI_NUMERICHOST
Specifies that the hostname value is a numeric address string. If this flag is set
and hostname is not a numeric address string, the returned address is set to
EAI_NONAME.
You can use this flag to prevent a name resolution service from being called.
AI_NUMERICSERV
Specifies that the service value is a nonNULL numeric port string. If this flag is
set and service is not a numeric port string, the function returns the error
EAI_NONAME.
You can use this flag to prevent a name resolution service from being called.
AI_PASSIVE Returns an address that can be passed to the bind( ) function. If hostname is
NULL, the address is set to INADDR_ANY or IN6ADDR_ANY_INIT,as
appropriate for the address family.
If this flag is not set, the returned address can be passed to the co
n
nect( ) func-
tion. If hostname is NULL, the address is set to the loopback address.
527187-017 Hewlett-Packard Company 3−11