1N/A - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 1N/A - Copyright (C) 2001, 2003 Internet Software Consortium. 1N/A - Permission to use, copy, modify, and distribute this software for any 1N/A - purpose with or without fee is hereby granted, provided that the above 1N/A - copyright notice and this permission notice appear in all copies. 1N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 1N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 1N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 1N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 1N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 1N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 1N/A - PERFORMANCE OF THIS SOFTWARE. 1N/A>lwres_getaddrinfo</
TITLE CONTENT="Modular DocBook HTML Stylesheet Version 1.73 >lwres_getaddrinfo, lwres_freeaddrinfo -- socket address structure to host and service name</
DIV>(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res);</
CODE>(struct addrinfo *ai);</
CODE>If the operating system does not provide a
the following structure is used:
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
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 hostname */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
is used to get a list of IP addresses and port numbers for host
The function is the lightweight resolver's implementation of
are pointers to null-terminated
is either a host name or a numeric host address string: a dotted decimal
IPv4 address or an IPv6 address.
is either a decimal port number or a service name as listed in
is an optional pointer to a
This structure can be used to provide hints concerning the type of socket
that the caller supports or wishes to use.
The caller can supply the following structure elements in
>The protocol family that should be used.
it means the caller will accept any protocol family supported by the
>denotes the type of socket —
is zero the caller will accept any socket type.</
P>indicates which transport protocol is wanted: IPPROTO_UDP or
is zero the caller will accept any protocol.</
Pbit is set, a successful call to
will return a null-terminated string containing the canonical name
of the specified hostname in
bit indicates that the returned socket address structure is intended
In this case, if the hostname argument is a
pointer, then the IP address portion of the socket
address structure will be set to
bit, the returned socket address structure will be ready
for a connection-oriented protocol or
if a connectionless protocol was chosen.
The IP address portion of the socket address structure will be
set to the loopback address if
should be treated as a numeric string defining an IPv4 or IPv6 address
and no name resolution should be attempted.</
P>All other elements of the <
SPANthe caller provided a <
SPAN>After a successful call to
is a pointer to a linked list of one or more
in this list cn be processed by following
structure contain the corresponding arguments for a call to
structure in the list, the
member points to a filled-in socket address structure of length
>All of the information returned by
is dynamically allocated: the addrinfo structures, and the socket
address structures and canonical host name strings pointed to by the
Memory allocated for the dynamically allocated structures created by
>lwres_freeaddrinfo()</
TTreturns zero on success or one of the error codes listed in
>lwres_freeaddrinfo</
SPAN>lwres_gai_strerror</
SPAN