<!DOCTYPE html PUBLIC "‐//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">     <html
xmlns="http://www.w3.org/1999/xhtml"> <head>
    <link            rel="stylesheet"             type="text/css"
href="../../../style.css" title="style" />
    <link  rel="stylesheet"  type="text/css"  href="../style.css"
title="style" />
    <meta             http‐equiv="content‐type"              con‐
tent="text/html;charset=utf‐8" />

    <title>netdb.h.0p ‐ Linux manual page</title> </head>

<body>

<div        class="page‐top"><a       id="top_of_page"></a></div>
<!‐‐%%%TOP_BAR%%%‐‐> <!‐‐%%%PAGE_START%%%‐‐>

<table class="sec‐table"> <tr>
    <td>
        <p class="section‐dir"> <a href="#PROLOG">PROLOG</a> | <a
href="#NAME">NAME</a>  |  <a  href="#SYNOPSIS">SYNOPSIS</a>  | <a
href="#DESCRIPTION">DESCRIPTION</a> |  <a  href="#APPLICATION_US‐
AGE">APPLICATION&nbsp;USAGE</a>   |  <a  href="#RATIONALE">RATIO‐
NALE</a>   |   <a    href="#FUTURE_DIRECTIONS">FUTURE&nbsp;DIREC‐
TIONS</a>    |   <a   href="#SEE_ALSO">SEE&nbsp;ALSO</a>   |   <a
href="#COPYRIGHT">COPYRIGHT</a>
        </p>
    </td>
    <td class="search‐box">
        <div class="man‐search‐box">

            <form                method="get"                 ac‐
tion="http://www.google.com/search">
                <fieldset class="man‐search">
                    <input    type="text"    name="q"   size="10"
maxlength="255" value="" />
                    <input type="hidden"  name="sitesearch"  val‐
ue="man7.org/linux/man‐pages" />
                    <input  type="submit" name="sa" value="Search
online pages" />
                </fieldset>
            </form>

        </div>
    </td>
    <td> </td> </tr> </table>

<pre> <span class="headline">netdb.h(0P)               POSIX Pro‐
grammer’s  Manual               netdb.h(0P)</span>  </pre> <h2><a
id="PROLOG" href="#PROLOG"></a>PROLOG  &nbsp; &nbsp; &nbsp;  &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       This manual page is part of the POSIX Programmer’s Manual.
The Linux
       implementation of this interface may differ (consult the
       corresponding  Linux  manual page for details of Linux be‐
havior), or
       the interface may not be  implemented  on  Linux.   </pre>
<h2><a id="NAME" href="#NAME"></a>NAME  &nbsp; &nbsp; &nbsp; &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       netdb.h  —  definitions  for  network  database operations
</pre> <h2><a id="SYNOPSIS" href="#SYNOPSIS"></a>SYNOPSIS  &nbsp;
&nbsp;  &nbsp;  &nbsp;  <a  href="#top_of_page"><span class="top‐
link">top</span></a></h2><pre>
       #include &lt;netdb.h&gt;  </pre>  <h2><a  id="DESCRIPTION"
href="#DESCRIPTION"></a>DESCRIPTION   &nbsp; &nbsp; &nbsp; &nbsp;
<a             href="#top_of_page"><span              class="top‐
link">top</span></a></h2><pre>
       The   <i>&lt;netdb.h&gt;</i>   header   may   define   the
<b>in_port_t </b>type and the <b>in_addr_t</b>
       type as described in <i>&lt;netinet/in.h&gt;</i>.

       The <i>&lt;netdb.h&gt;</i> header shall define the <b>hos‐
tent </b>structure, which shall
       include at least the following members:

           <b>char   *h_name       </b>Official name of the host.
           char  **h_aliases    A pointer to an array of pointers
to
                                alternative host names, terminat‐
ed by a
                                null pointer.
           int     h_addrtype   Address type.
           int      h_length     The length, in bytes, of the ad‐
dress.
           char  **h_addr_list  A pointer to an array of pointers
to network
                                addresses (in network byte order)
for the host,
                                terminated by a null pointer.

       The <i>&lt;netdb.h&gt;</i> header shall define the  <b>ne‐
tent </b>structure, which shall
       include at least the following members:

           <b>char     *n_name      </b>Official, fully‐qualified
(including the
                                 domain) name of the host.
           char    **n_aliases   A pointer to an array of  point‐
ers to
                                 alternative  network names, ter‐
minated by a
                                 null pointer.
           int       n_addrtype  The address type of the network.
           uint32_t  n_net       The network number, in host byte
order.

       The   <i>&lt;netdb.h&gt;</i>   header   shall  define  the
<b>uint32_t </b>type as described in
       <i>&lt;inttypes.h&gt;</i>.

       The <i>&lt;netdb.h&gt;</i> header shall define the <b>pro‐
toent </b>structure, which shall
       include at least the following members:

           <b>char    *p_name     </b>Official name of the proto‐
col.
           char  **p_aliases  A pointer to an array  of  pointers
to
                              alternative  protocol names, termi‐
nated by
                              a null pointer.
           int     p_proto    The protocol number.

       The <i>&lt;netdb.h&gt;</i> header shall define the <b>ser‐
vent </b>structure, which shall
       include at least the following members:

           <b>char    *s_name      </b>Official  name of the ser‐
vice.
           char  **s_aliases  A pointer to an array  of  pointers
to
                              alternative  service  names, termi‐
nated by
                              a null pointer.
           int     s_port     A value which,  when  converted  to
uint16_t,
                              yields  the  port number in network
byte order
                              at which the service resides.
           char   *s_proto    The name of  the  protocol  to  use
when
                              contacting the service.

       The  <i>&lt;netdb.h&gt;</i>  header  shall  define the IP‐
PORT_RESERVED symbolic
       constant with the value of the highest  reserved  Internet
port number.

   <b>Address Information Structure</b>
       The  <i>&lt;netdb.h&gt;</i> header shall define the <b>ad‐
drinfo </b>structure, which shall
       include at least the following members:

           <b>int               ai_flags      </b>Input flags.
           int                ai_family      Address  family   of
socket.
           int               ai_socktype   Socket type.
           int               ai_protocol   Protocol of socket.
           socklen_t          ai_addrlen     Length of socket ad‐
dress.
           struct  sockaddr   *ai_addr        Socket  address  of
socket.
           char             *ai_canonname  Canonical name of ser‐
vice location.
           struct addrinfo  *ai_next        Pointer  to  next  in
list.

       The <i>&lt;netdb.h&gt;</i> header shall define the follow‐
ing symbolic constants
       that evaluate to bitwise‐distinct  integer  constants  for
use in the
       <i>flags</i> field of the <b>addrinfo </b>structure:

       AI_PASSIVE       Socket    address    is    intended   for
<i>bind</i>().

       AI_CANONNAME  Request for canonical name.

       AI_NUMERICHOST
                     Return numeric host address as name.

       AI_NUMERICSERV
                     Inhibit service name resolution.

       AI_V4MAPPED   If no IPv6 addresses are  found,  query  for
IPv4
                     addresses  and  return them to the caller as
IPv4‐mapped
                     IPv6 addresses.

       AI_ALL        Query for both IPv4 and IPv6 addresses.

       AI_ADDRCONFIG Query for IPv4 addresses only when  an  IPv4
address is
                     configured;  query  for  IPv6 addresses only
when an IPv6
                     address is configured.

       The <i>&lt;netdb.h&gt;</i> header shall define the follow‐
ing symbolic constants
       that  evaluate  to  bitwise‐distinct integer constants for
use in the
       <i>flags</i> argument to <i>getnameinfo</i>():

       NI_NOFQDN     Only the nodename portion of the FQDN is re‐
turned for
                     local hosts.

       NI_NUMERICHOST
                     The  numeric  form  of the node’s address is
returned
                     instead of its name.

       NI_NAMEREQD   Return an error if the node’s name cannot be
located in
                     the database.

       NI_NUMERICSERV
                     The  numeric  form of the service address is
returned
                     instead of its name.

       NI_NUMERICSCOPE
                     For IPv6 addresses, the numeric form of  the
scope
                     identifier is returned instead of its name.

       NI_DGRAM       Indicates  that  the  service is a datagram
service
                     (SOCK_DGRAM).

   <b>Address Information Errors</b>
       The <i>&lt;netdb.h&gt;</i> header shall define the follow‐
ing symbolic constants
       for  use  as  error  values  for  <i>getaddrinfo</i>() and
<i>getnameinfo</i>().  The
       values shall be suitable for use in <b>#if </b>preprocess‐
ing directives.

       EAI_AGAIN     The name could not be resolved at this time.
Future
                     attempts may succeed.

       EAI_BADFLAGS  The flags had an invalid value.

       EAI_FAIL      A non‐recoverable error occurred.

       EAI_FAMILY    The address family was not recognized or the
address
                     length was invalid for the specified family.

       EAI_MEMORY    There was a memory allocation failure.

       EAI_NONAME     The  name does not resolve for the supplied
parameters.

                     NI_NAMEREQD is set and the host’s name  can‐
not be
                     located,   or   both   <i>nodename</i>   and
<i>servname</i> were null.

       EAI_SERVICE   The service passed was  not  recognized  for
the specified
                     socket type.

       EAI_SOCKTYPE  The intended socket type was not recognized.

       EAI_SYSTEM     A system error occurred. The error code can
be found in
                     <i><a        href="../man3/errno.3.html">er‐
rno</a></i>.

       EAI_OVERFLOW  An argument buffer overflowed.

       The  following shall be declared as functions and may also
be defined
       as macros. Function prototypes shall be provided.

           <b>void              endhostent(void);</b>
           <b>void              endnetent(void);</b>
           <b>void              endprotoent(void);</b>
           <b>void              endservent(void);</b>
           <b>void                freeaddrinfo(struct    addrinfo
*);</b>
           <b>const char       *gai_strerror(int);</b>
           <b>int               getaddrinfo(const char *restrict,
const char *restrict,</b>
                                 <b>const  struct  addrinfo  *re‐
strict,</b>
                                 <b>struct     addrinfo     **re‐
strict);</b>
           <b>struct hostent   *gethostent(void);</b>
           <b>int               getnameinfo(const struct sockaddr
*restrict, socklen_t,</b>
                                 <b>char   *restrict,  socklen_t,
char *restrict,</b>
                                 <b>socklen_t, int);</b>
           <b>struct netent    *getnetbyaddr(uint32_t, int);</b>
           <b>struct netent    *getnetbyname(const char *);</b>
           <b>struct netent    *getnetent(void);</b>
           <b>struct protoent  *getprotobyname(const char *);</b>
           <b>struct protoent  *getprotobynumber(int);</b>
           <b>struct protoent  *getprotoent(void);</b>
           <b>struct servent   *getservbyname(const char *, const
char *);</b>
           <b>struct  servent    *getservbyport(int,  const  char
*);</b>
           <b>struct servent   *getservent(void);</b>
           <b>void              sethostent(int);</b>
           <b>void              setnetent(int);</b>
           <b>void              setprotoent(int);</b>
           <b>void              setservent(int);</b>

       The  <i>&lt;netdb.h&gt;</i>  header   shall   define   the
<b>socklen_t </b>type through <b>typedef</b>,
       as described in <i>&lt;sys/socket.h&gt;</i>.

       Inclusion  of  the  <i>&lt;netdb.h&gt;</i> header may also
make visible all symbols
       from     <i>&lt;netinet/in.h&gt;</i>,     <i>&lt;sys/sock‐
et.h&gt;</i>, and <i>&lt;inttypes.h&gt;</i>.

       <i>The  following  sections  are  informative.</i>  </pre>
<h2><a  id="APPLICATION_USAGE"  href="#APPLICATION_USAGE"></a>AP‐
PLICATION    USAGE     &nbsp;    &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       None.     </pre>   <h2><a   id="RATIONALE"   href="#RATIO‐
NALE"></a>RATIONALE    &nbsp;    &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       None.   </pre>  <h2><a  id="FUTURE_DIRECTIONS"  href="#FU‐
TURE_DIRECTIONS"></a>FUTURE DIRECTIONS  &nbsp; &nbsp; &nbsp; &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       None.     </pre>   <h2><a   id="SEE_ALSO"   href="#SEE_AL‐
SO"></a>SEE   ALSO     &nbsp;    &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       <a   href="../man0/inttypes.h.0p.html">inttypes.h(0p)</a>,
<a  href="../man0/netinet_in.h.0p.html">netinet_in.h(0p)</a>,  <a
href="../man0/sys_socket.h.0p.html">sys_socket.h(0p)</a>

       The  System  Interfaces   volume   of   POSIX.1‐2008,   <a
href="../man3/bind.3p.html">bind(3p)</a>,
       <a   href="../man3/endhostent.3p.html">endhostent(3p)</a>,
<a     href="../man3/endnetent.3p.html">endnetent(3p)</a>,     <a
href="../man3/endprotoent.3p.html">endprotoent(3p)</a>,        <a
href="../man3/endservent.3p.html">endservent(3p)</a>,
       <a         href="../man3/freeaddrinfo.3p.html">freeaddrin‐
fo(3p)</a>,    <a    href="../man3/gai_strerror.3p.html">gai_str‐
error(3p)</a>,  <a  href="../man3/getnameinfo.3p.html">getnamein‐
fo(3p)</a>     </pre>    <h2><a    id="COPYRIGHT"    href="#COPY‐
RIGHT"></a>COPYRIGHT    &nbsp;   &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       Portions of this text  are  reprinted  and  reproduced  in
electronic form
       from  IEEE Std 1003.1, 2013 Edition, Standard for Informa‐
tion
       Technology ‐‐ Portable Operating System Interface (POSIX),
The Open
       Group  Base  Specifications Issue 7, Copyright (C) 2013 by
the
       Institute of Electrical and Electronics Engineers, Inc and
The Open
       Group.  (This is POSIX.1‐2008 with the 2013 Technical Cor‐
rigendum 1
       applied.) In the event of  any  discrepancy  between  this
version and
       the  original IEEE and The Open Group Standard, the origi‐
nal IEEE and
       The Open Group Standard is the referee document. The orig‐
inal
       Standard     can     be     obtained    online    at    <a
href="http://www.unix.org/online.html">http://www.unix.org/on‐
line.html</a> .

       Any typographical or formatting errors that appear in this
page are
       most likely to have been introduced during the  conversion
of the
       source  files  to  man page format. To report such errors,
see
       <a      href="https://www.kernel.org/doc/man‐pages/report‐
ing_bugs.html">https://www.kernel.org/doc/man‐pages/report‐
ing_bugs.html</a> .

<span class="footline">IEEE/The Open  Group                  2013
netdb.h(0P)</span> </pre>

<hr class="end‐man‐text" />

<hr class="start‐footer" />

<div class="footer">

<table class="colophon‐table">
    <tr>
    <td class="pub‐info">
        <p>
            HTML rendering created 2019‐08‐02
            by  <a  href="http://man7.org/mtk/index.html">Michael
Kerrisk</a>,
            author of
            <a  href="http://man7.org/tlpi/"><em>The  Linux  Pro‐
gramming Interface</em></a>,
            maintainer of the
            <a href="https://www.kernel.org/doc/man‐pages/">Linux
<em>man‐pages</em> project</a>.
        </p>
        <p>
            For details of in‐depth
            <strong>Linux/UNIX system programming training  cour‐
ses</strong>
            that  I  teach,  look <a href="http://man7.org/train‐
ing/">here</a>.
        </p>
        <p>
            Hosting   by    <a    href="http://www.jambit.com/in‐
dex_en.html">jambit GmbH</a>.
        </p>
        <p>
            <a href="http://validator.w3.org/check?uri=referer">
            <img src="http://www.w3.org/Icons/valid‐xhtml11"
                alt="Valid XHTML 1.1" height="31" width="88" />
            </a>
        </p>
    </td>
    <td class="colophon‐divider">
    </td>
    <td class="tlpi‐cover">
        <a                      href="http://man7.org/tlpi/"><img
src="http://man7.org/tlpi/cover/TLPI‐front‐cover‐vsmall.png"
alt="Cover of TLPI" /></a>
    </td>
    </tr> </table>

</div>

<hr class="end‐footer" />

</body> </html>