lwres_getaddrinfo.docbook revision ec5347e2c775f027573ce5648b910361aa926c01
5cd4555ad444fd391002ae32450572054369fd42Rob Austein<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
5cd4555ad444fd391002ae32450572054369fd42Rob Austein "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein [<!ENTITY mdash "&#8212;">]>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<!--
938440694b33cd752e9e4b71a526368b4811c177Tinderbox User - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson -
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater - Permission to use, copy, modify, and/or distribute this software for any
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - purpose with or without fee is hereby granted, provided that the above
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - copyright notice and this permission notice appear in all copies.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson -
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - PERFORMANCE OF THIS SOFTWARE.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson-->
f5d30e2864e048a42c4dc1134993ae7efdb5d6c3Mark Andrews
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<!-- $Id: lwres_getaddrinfo.docbook,v 1.13 2007/06/18 23:47:51 tbox Exp $ -->
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
1753d3c4d74241a847794f7e7cfd94cc79be6600Evan Hunt <refentryinfo>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <date>Jun 30, 2000</date>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </refentryinfo>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refmeta>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refentrytitle>lwres_getaddrinfo</refentrytitle>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <manvolnum>3</manvolnum>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refmiscinfo>BIND9</refmiscinfo>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </refmeta>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <docinfo>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <copyright>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <year>2004</year>
c1a883f2e04d94e99c433b1f6cfd0c0338f4ed85Mark Andrews <year>2005</year>
938440694b33cd752e9e4b71a526368b4811c177Tinderbox User <year>2007</year>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </copyright>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <copyright>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <year>2000</year>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <year>2001</year>
f5d30e2864e048a42c4dc1134993ae7efdb5d6c3Mark Andrews <year>2003</year>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <holder>Internet Software Consortium.</holder>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </copyright>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </docinfo>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refnamediv>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refname>lwres_getaddrinfo</refname>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refname>lwres_freeaddrinfo</refname>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refpurpose>socket address structure to host and service name</refpurpose>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </refnamediv>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refsynopsisdiv>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <funcsynopsis>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<funcsynopsisinfo>#include &lt;lwres/netdb.h&gt;</funcsynopsisinfo>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<funcprototype>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonint
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_getaddrinfo</function></funcdef>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <paramdef>const char *<parameter>hostname</parameter></paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <paramdef>const char *<parameter>servname</parameter></paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <paramdef>const struct addrinfo *<parameter>hints</parameter></paramdef>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <paramdef>struct addrinfo **<parameter>res</parameter></paramdef>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </funcprototype>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<funcprototype>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <funcdef>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinvoid
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_freeaddrinfo</function></funcdef>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <paramdef>struct addrinfo *<parameter>ai</parameter></paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcsynopsis>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein If the operating system does not provide a
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>struct addrinfo</type>,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the following structure is used:
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para><programlisting>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct addrinfo {
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein int ai_family; /* PF_xxx */
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein int ai_socktype; /* SOCK_xxx */
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein size_t ai_addrlen; /* length of ai_addr */
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein char *ai_canonname; /* canonical name for hostname */
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson struct sockaddr *ai_addr; /* binary address */
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein struct addrinfo *ai_next; /* next structure in linked list */
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson};
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</programlisting>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </refsynopsisdiv>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <title>DESCRIPTION</title>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <para><function>lwres_getaddrinfo()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson is used to get a list of IP addresses and port numbers for host
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <parameter>hostname</parameter> and service
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <parameter>servname</parameter>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson The function is the lightweight resolver's implementation of
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <function>getaddrinfo()</function> as defined in RFC2133.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <parameter>hostname</parameter> and
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <parameter>servname</parameter> are pointers to null-terminated
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein strings or <type>NULL</type>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <parameter>hostname</parameter> is either a host name or a
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson numeric host address string: a dotted decimal IPv4 address or an
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein IPv6 address. <parameter>servname</parameter> is either a
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein decimal port number or a service name as listed in
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <filename>/etc/services</filename>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para><parameter>hints</parameter>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is an optional pointer to a
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>struct addrinfo</type>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein This structure can be used to provide hints concerning the type of
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein socket
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein that the caller supports or wishes to use.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein The caller can supply the following structure elements in
821350367e2c7313c02eb275e8e05d5193b47cfdJeremy C. Reed <parameter>*hints</parameter>:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <variablelist>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <varlistentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <term><constant>ai_family</constant></term>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <listitem>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein The protocol family that should be used.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein When
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <constant>ai_family</constant>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is set to
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>PF_UNSPEC</type>,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein it means the caller will accept any protocol family supported by
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein operating system.
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </listitem>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </varlistentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <term><constant>ai_socktype</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <listitem>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein denotes the type of socket &mdash;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>SOCK_STREAM</type>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <type>SOCK_DGRAM</type>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson or
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson <type>SOCK_RAW</type>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson &mdash; that is wanted.
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson When
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <constant>ai_socktype</constant>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is zero the caller will accept any socket type.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </varlistentry>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson <varlistentry>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson <term><constant>ai_protocol</constant></term>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson <listitem>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson <para>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson indicates which transport protocol is wanted: IPPROTO_UDP or
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson IPPROTO_TCP.
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson If
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson <constant>ai_protocol</constant>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson is zero the caller will accept any protocol.
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson </para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </varlistentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <varlistentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <term><constant>ai_flags</constant></term>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <listitem>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Flag bits.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein If the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>AI_CANONNAME</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein bit is set, a successful call to
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson <function>lwres_getaddrinfo()</function>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein will return a null-terminated string containing the canonical
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein name
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein of the specified hostname in
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <constant>ai_canonname</constant>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein of the first
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>addrinfo</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein structure returned.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson Setting the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>AI_PASSIVE</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein bit indicates that the returned socket address structure is
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein intended
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for used in a call to
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </citerefentry>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson In this case, if the hostname argument is a
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>NULL</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein pointer, then the IP address portion of the socket
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein address structure will be set to
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>INADDR_ANY</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for an IPv4 address or
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>IN6ADDR_ANY_INIT</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for an IPv6 address.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein When
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <constant>ai_flags</constant>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein does not set the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>AI_PASSIVE</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein bit, the returned socket address structure will be ready
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for use in a call to
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for a connection-oriented protocol or
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </citerefentry>,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refentrytitle>sendto</refentrytitle><manvolnum>2</manvolnum>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </citerefentry>,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein or
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <refentrytitle>sendmsg</refentrytitle><manvolnum>2</manvolnum>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </citerefentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein if a connectionless protocol was chosen.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein The IP address portion of the socket address structure will be
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein set to the loopback address if
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <parameter>hostname</parameter>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is a
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>NULL</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein pointer and
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>AI_PASSIVE</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is not set in
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <constant>ai_flags</constant>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein If
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <constant>ai_flags</constant>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is set to
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <type>AI_NUMERICHOST</type>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein it indicates that
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <parameter>hostname</parameter>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein should be treated as a numeric string defining an IPv4 or IPv6
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein address
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein and no name resolution should be attempted.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </listitem>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </varlistentry>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </variablelist>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein All other elements of the <type>struct addrinfo</type> passed
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein via <parameter>hints</parameter> must be zero.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <para>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein A <parameter>hints</parameter> of <type>NULL</type> is
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein treated as if
the caller provided a <type>struct addrinfo</type> initialized to zero
with <constant>ai_family</constant>set to
<constant>PF_UNSPEC</constant>.
</para>
<para>
After a successful call to
<function>lwres_getaddrinfo()</function>,
<parameter>*res</parameter>
is a pointer to a linked list of one or more
<type>addrinfo</type>
structures.
Each
<type>struct addrinfo</type>
in this list cn be processed by following
the
<constant>ai_next</constant>
pointer, until a
<type>NULL</type>
pointer is encountered.
The three members
<constant>ai_family</constant>,
<constant>ai_socktype</constant>,
and
<constant>ai_protocol</constant>
in each
returned
<type>addrinfo</type>
structure contain the corresponding arguments for a call to
<citerefentry>
<refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum>
</citerefentry>.
For each
<type>addrinfo</type>
structure in the list, the
<constant>ai_addr</constant>
member points to a filled-in socket address structure of length
<constant>ai_addrlen</constant>.
</para>
<para>
All of the information returned by
<function>lwres_getaddrinfo()</function>
is dynamically allocated: the addrinfo structures, and the socket
address structures and canonical host name strings pointed to by the
<constant>addrinfo</constant>structures.
Memory allocated for the dynamically allocated structures created by
a successful call to
<function>lwres_getaddrinfo()</function>
is released by
<function>lwres_freeaddrinfo()</function>.
<parameter>ai</parameter>
is a pointer to a
<type>struct addrinfo</type>
created by a call to
<function>lwres_getaddrinfo()</function>.
</para>
</refsect1>
<refsect1>
<title>RETURN VALUES</title>
<para><function>lwres_getaddrinfo()</function>
returns zero on success or one of the error codes listed in
<citerefentry>
<refentrytitle>gai_strerror</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>
if an error occurs. If both <parameter>hostname</parameter> and
<parameter>servname</parameter> are <type>NULL</type>
<function>lwres_getaddrinfo()</function> returns
<errorcode>EAI_NONAME</errorcode>.
</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para><citerefentry>
<refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_freeaddrinfo</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_gai_strerror</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>RFC2133</refentrytitle>
</citerefentry>,
<citerefentry>
<refentrytitle>getservbyname</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>sendto</refentrytitle><manvolnum>2</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>sendmsg</refentrytitle><manvolnum>2</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum>
</citerefentry>.
</para>
</refsect1>
</refentry><!--
- Local variables:
- mode: sgml
- End:
-->