<!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>netinet_in.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">netinet_in.h(0P)          POSIX Pro‐
grammer’s  Manual          netinet_in.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>
       netinet/in.h  —  Internet  address  family  </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;netinet/in.h&gt; </pre>  <h2><a  id="DESCRIP‐
TION"  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;netinet/in.h&gt;</i>  header  shall define the
following types:

       <b>in_port_t </b>Equivalent to the type <b>uint16_t </b>as
described in
                 <i>&lt;inttypes.h&gt;</i>.

       <b>in_addr_t </b>Equivalent to the type <b>uint32_t </b>as
described in
                 <i>&lt;inttypes.h&gt;</i>.

       The <i>&lt;netinet_in.h&gt;</i> header  shall  define  the
<b>sa_family_t </b>type as
       described in <i>&lt;sys/socket.h&gt;</i>.

       The  <i>&lt;netinet_in.h&gt;</i>  header  shall define the
<b>uint8_t </b>and <b>uint32_t </b>types
       as described in <i>&lt;inttypes.h&gt;</i>.   Inclusion  of
the <i>&lt;netinet/in.h&gt;</i> header
       may   also  make  visible  all  symbols  from  <i>&lt;int‐
types.h&gt;</i> and
       <i>&lt;sys/socket.h&gt;</i>.

       The <i>&lt;netinet/in.h&gt;</i> header  shall  define  the
<b>in_addr </b>structure, which
       shall include at least the following member:

           <b>in_addr_t  s_addr</b>

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
<b>sockaddr_in </b>structure,
       which shall include at least the following members:

           <b>sa_family_t     sin_family   </b>AF_INET.
           in_port_t       sin_port     Port number.
           struct in_addr  sin_addr     IP address.

       The <i>sin_port</i> and <i>sin_addr</i> members  shall  be
in network byte order.

       The <b>sockaddr_in </b>structure is used to store address‐
es for the Internet
       address family.  Pointers to this type shall  be  cast  by
applications
       to <b>struct sockaddr * </b>for use with socket functions.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
<b>in6_addr </b>structure, which
       shall include at least the following member:

           <b>uint8_t s6_addr[16]</b>

       This array is used to  contain  a  128‐bit  IPv6  address,
stored in
       network byte order.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
<b>sockaddr_in6 </b>structure,
       which shall include at least the following members:

           <b>sa_family_t      sin6_family    </b>AF_INET6.
           in_port_t        sin6_port      Port number.
           uint32_t         sin6_flowinfo  IPv6 traffic class and
flow information.
           struct in6_addr  sin6_addr      IPv6 address.
           uint32_t          sin6_scope_id  Set of interfaces for
a scope.

       The <i>sin6_port</i> and <i>sin6_addr</i> members shall be
in network byte order.

       The  <b>sockaddr_in6 </b>structure shall be set to zero by
an application
       prior to using it, since implementations are free to  have
additional,
       implementation‐defined fields in <b>sockaddr_in6</b>.

       The  <i>sin6_scope_id</i>  field  is a 32‐bit integer that
identifies a set of
       interfaces as appropriate for the  scope  of  the  address
carried in the
       <i>sin6_addr</i> field. For a link scope <i>sin6_addr</i>,
the application shall
       ensure that <i>sin6_scope_id</i> is a link  index.  For  a
site scope
       <i>sin6_addr</i>,   the   application  shall  ensure  that
<i>sin6_scope_id</i> is a site
       index. The mapping of <i>sin6_scope_id</i> to an interface
or set of
       interfaces is implementation‐defined.

       The  <i>&lt;netinet/in.h&gt;</i>  header shall declare the
following external
       variable:

           <b>const struct in6_addr in6addr_any</b>

       This variable is initialized by the system to contain  the
wildcard
       IPv6  address. The <i>&lt;netinet/in.h&gt;</i> header also
defines the
       IN6ADDR_ANY_INIT macro. This macro  must  be  constant  at
compile time
       and can be used to initialize a variable of type <b>struct
in6_addr </b>to
       the IPv6 wildcard address.

       The <i>&lt;netinet/in.h&gt;</i> header shall  declare  the
following external
       variable:

           <b>const struct in6_addr in6addr_loopback</b>

       This  variable is initialized by the system to contain the
loopback
       IPv6 address. The <i>&lt;netinet/in.h&gt;</i> header  also
defines the
       IN6ADDR_LOOPBACK_INIT  macro.  This macro must be constant
at compile
       time and can be used to  initialize  a  variable  of  type
<b>struct in6_addr</b>
       to the IPv6 loopback address.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
<b>ipv6_mreq </b>structure, which
       shall include at least the following members:

           <b>struct in6_addr  ipv6mr_multiaddr  </b>IPv6  multi‐
cast address.
           unsigned         ipv6mr_interface  Interface index.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
following symbolic
       constants for use as values of the  <i>level</i>  argument
of <i>getsockopt</i>() and
       <i>setsockopt</i>():

       IPPROTO_IP      Internet protocol.

       IPPROTO_IPV6    Internet Protocol Version 6.

       IPPROTO_ICMP    Control message protocol.

       IPPROTO_RAW     Raw IP Packets Protocol.

       IPPROTO_TCP     Transmission control protocol.

       IPPROTO_UDP     User datagram protocol.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
following symbolic
       constants for use as  destination  addresses  for  <i>con‐
nect</i>(), <i>sendmsg</i>(),
       and <i>sendto</i>():

       INADDR_ANY      IPv4 local host address.

       INADDR_BROADCAST
                       IPv4 broadcast address.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
following symbolic
       constant, with the value specified, to  help  applications
declare
       buffers  of  the  proper  size  to store IPv4 addresses in
string form:

       INET_ADDRSTRLEN 16. Length of the string form for IP.

       The <i>htonl</i>(),  <i>htons</i>(),  <i>ntohl</i>(),  and
<i>ntohs</i>() functions shall be
       available as described in <i>&lt;arpa/inet.h&gt;</i>.  In‐
clusion of the
       <i>&lt;netinet/in.h&gt;</i> header may also  make  visible
all symbols from
       <i>&lt;arpa/inet.h&gt;</i>.

       The  <i>&lt;netinet/in.h&gt;</i>  header  shall define the
following symbolic
       constant, with the value specified, to  help  applications
declare
       buffers  of  the  proper  size  to store IPv6 addresses in
string form:

       INET6_ADDRSTRLEN
                       46. Length of the string form for IPv6.

       The <i>&lt;netinet/in.h&gt;</i> header  shall  define  the
following symbolic
       constants,  with  distinct  integer values, for use in the
<i>option_name</i>
       argument in the <i>getsockopt</i>() or <i>setsockopt</i>()
functions at protocol
       level IPPROTO_IPV6:

       IPV6_JOIN_GROUP Join a multicast group.

       IPV6_LEAVE_GROUP
                       Quit a multicast group.

       IPV6_MULTICAST_HOPS
                       Multicast hop limit.

       IPV6_MULTICAST_IF
                       Interface  to  use  for outgoing multicast
packets.

       IPV6_MULTICAST_LOOP
                       Multicast packets are  delivered  back  to
the local
                       application.

       IPV6_UNICAST_HOPS
                       Unicast hop limit.

       IPV6_V6ONLY      Restrict AF_INET6 socket to IPv6 communi‐
cations only.

       The <i>&lt;netinet/in.h&gt;</i> header  shall  define  the
following macros that test
       for  special  IPv6 addresses. Each macro is of type <b>int
</b>and takes a
       single argument of type <b>const struct in6_addr *</b>:

       IN6_IS_ADDR_UNSPECIFIED
             Unspecified address.

       IN6_IS_ADDR_LOOPBACK
             Loopback address.

       IN6_IS_ADDR_MULTICAST
             Multicast address.

       IN6_IS_ADDR_LINKLOCAL
             Unicast link‐local address.

       IN6_IS_ADDR_SITELOCAL
             Unicast site‐local address.

       IN6_IS_ADDR_V4MAPPED
             IPv4 mapped address.

       IN6_IS_ADDR_V4COMPAT
             IPv4‐compatible address.

       IN6_IS_ADDR_MC_NODELOCAL
             Multicast node‐local address.

       IN6_IS_ADDR_MC_LINKLOCAL
             Multicast link‐local address.

       IN6_IS_ADDR_MC_SITELOCAL
             Multicast site‐local address.

       IN6_IS_ADDR_MC_ORGLOCAL
             Multicast organization‐local address.

       IN6_IS_ADDR_MC_GLOBAL
             Multicast global address.

       <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>
       <i>Section  4.9</i>,  <i>Host and Network Byte Orders</i>,
<a href="../man0/arpa_inet.h.0p.html">arpa_inet.h(0p)</a>,
       <a   href="../man0/inttypes.h.0p.html">inttypes.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/connect.3p.html">connect(3p)</a>,
       <a   href="../man3/getsockopt.3p.html">getsockopt(3p)</a>,
<a         href="../man3/htonl.3p.html">htonl(3p)</a>,         <a
href="../man3/sendmsg.3p.html">sendmsg(3p)</a>,                <a
href="../man3/sendto.3p.html">sendto(3p)</a>,                  <a
href="../man3/setsockopt.3p.html">setsockopt(3p)</a>       </pre>
<h2><a   id="COPYRIGHT"  href="#COPYRIGHT"></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
netinet_in.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>