1216 Chapter 59
The hints.ai_flags field is a bit mask that modifies the behavior of getaddrinfo().
This field is formed by ORing together zero or more of the following values:
AI_ADDRCONFIG
Return IPv4 addresses only if there is at least one IPv4 address configured
for the local system (other than the IPv4 loopback address), and return
IPv6 addresses only if there is at least one IPv6 address configured for the
local system (other than the IPv6 loopback address).
AI_ALL
See the description of AI_V4MAPPED below.
AI_CANONNAME
If host is not NULL, return a pointer to a null-terminated string containing
the canonical name of the host. This pointer is returned in a buffer
pointed to by the ai_canonname field of the first of the addrinfo structures
returned via result.
AI_NUMERICHOST
Force interpretation of host as a numeric address string. This is used to prevent
name resolution in cases where it is unnecessary, since name resolution
can be time-consuming.
AI_NUMERICSERV
Interpret service as a numeric port number. This flag prevents the invoca-
tion of any name-resolution service, which is not required if service is a
numeric string.
AI_PASSIVE
Return socket address structures suitable for a passive open (i.e., a listen-
ing socket). In this case, host should be NULL, and the IP address component
of the socket address structure(s) returned by result will contain a wildcard
IP address (i.e., INADDR_ANY or IN6ADDR_ANY_INIT). If this flag is not set, then
the address structure(s) returned via result will be suitable for use with
connect() and sendto(); if host is NULL, then the IP address in the returned
socket address structures will be set to the loopback IP address (either
INADDR_LOOPBACK or IN6ADDR_LOOPBACK_INIT, according to the domain).
AI_V4MAPPED
If AF_INET6 was specified in the ai_family field of hints, then IPv4-mapped
IPv6 address structures should be returned in result if no matching IPv6
address could be found. If AI_ALL is specified in conjunction with AI_V4MAPPED,
then both IPv6 and IPv4 address structures are returned in result, with IPv4
addresses being returned as IPv4-mapped IPv6 address structures.
As noted above for AI_PASSIVE, host can be specified as NULL. It is also possible to
specify service as NULL, in which case the port number in the returned address struc-
tures is set to 0 (i.e., we are just interested in resolving hostnames to addresses). It
is not permitted, however, to specify both host and service as NULL.
If we don’t need to specify any of the above selection criteria in hints, then
hints may be specified as NULL, in which case ai_socktype and ai_protocol are assumed