
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- MyFirstUnitAd -->
<ins class="adsbygoogle"
     style="display:inline-block;width:970px;height:250px"
     data-ad-client="ca-pub-5778386704669218"
     data-ad-slot="1503492166"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

<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" content="text/html;charset=utf-8" />

    <title>getipnodebyname(3) - Linux manual page</title>
</head>

<body>

<div class="page-top"><a id="top_of_page"></a></div>
<!--%%%TOP_BAR%%%-->
    <div class="nav-bar">
        <table class="nav-table">
            <tr>
                <td class="nav-cell">
                    <p class="nav-text">
                        <a href="http://man7.org/index.html">man7.org</a> &gt; Linux &gt; <a href="../index.html">man-pages</a>
                    </p>
                </td>
                <td class="training-cell">
                    <p class="training-text"><a class="training-link" href="http://man7.org/training/">Linux/UNIX system programming training</a></p>
                </td>
            </tr>
        </table>
    </div>

<hr class="nav-end" />

<!--%%%PAGE_START%%%-->


<table class="sec-table">
<tr>
    <td>
        <p class="section-dir">
<a href="freehostent.3.html#NAME">NAME</a> | <a href="freehostent.3.html#SYNOPSIS">SYNOPSIS</a> | <a href="freehostent.3.html#DESCRIPTION">DESCRIPTION</a> | <a href="freehostent.3.html#RETURN_VALUE">RETURN&nbsp;VALUE</a> | <a href="freehostent.3.html#CONFORMING_TO">CONFORMING&nbsp;TO</a> | <a href="freehostent.3.html#NOTES">NOTES</a> | <a href="freehostent.3.html#SEE_ALSO">SEE&nbsp;ALSO</a> | <a href="freehostent.3.html#COLOPHON">COLOPHON</a>
        </p>
    </td>
    <td class="search-box">
        <div class="man-search-box">

            <form method="get" action="http://www.google.com/search">
                <fieldset class="man-search">
                    <input type="text" name="q" size="10" maxlength="255" value="" />
                    <input type="hidden" name="sitesearch" value="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">GETIPNODEBYNAME(3)        Linux Programmer's Manual       GETIPNODEBYNAME(3)</span>
</pre>
<h2><a id="NAME" href="freehostent.3.html#NAME"></a>NAME  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       getipnodebyname, getipnodebyaddr, freehostent - get network hostnames
       and addresses
</pre>
<h2><a id="SYNOPSIS" href="freehostent.3.html#SYNOPSIS"></a>SYNOPSIS  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       <b>#include &lt;sys/types.h&gt;</b>
       <b>#include &lt;sys/socket.h&gt;</b>
       <b>#include &lt;netdb.h&gt;</b>

       <b>struct hostent *getipnodebyname(const char *</b><i>name</i><b>, int </b><i>af</i><b>,</b>
                                       <b>int </b><i>flags</i><b>, int *</b><i>error_num</i><b>);</b>

       <b>struct hostent *getipnodebyaddr(const void *</b><i>addr</i><b>, size_t </b><i>len</i><b>,</b>
                                       <b>int </b><i>af</i><b>, int *</b><i>error_num</i><b>);</b>

       <b>void freehostent(struct hostent *</b><i>ip</i><b>);</b>
</pre>
<h2><a id="DESCRIPTION" href="freehostent.3.html#DESCRIPTION"></a>DESCRIPTION  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       These functions are deprecated (and unavailable in glibc).  Use
       <a href="getaddrinfo.3.html">getaddrinfo(3)</a> and <a href="getnameinfo.3.html">getnameinfo(3)</a> instead.

       The <b>getipnodebyname</b>() and <b>getipnodebyaddr</b>() functions return the
       names and addresses of a network host.  These functions return a
       pointer to the following structure:

           struct hostent {
               char  *h_name;
               char **h_aliases;
               int    h_addrtype;
               int    h_length;
               char **h_addr_list;
           };

       These functions replace the <a href="gethostbyname.3.html">gethostbyname(3)</a> and <a href="gethostbyaddr.3.html">gethostbyaddr(3)</a>
       functions, which could access only the IPv4 network address family.
       The <b>getipnodebyname</b>() and <b>getipnodebyaddr</b>() functions can access mul‐
       tiple network address families.

       Unlike the <b>gethostby </b>functions, these functions return pointers to
       dynamically allocated memory.  The <b>freehostent</b>() function is used to
       release the dynamically allocated memory after the caller no longer
       needs the <i>hostent</i> structure.

   <b>getipnodebyname() arguments</b>
       The <b>getipnodebyname</b>() function looks up network addresses for the
       host specified by the <i>name</i> argument.  The <i>af</i> argument specifies one
       of the following values:

       <b>AF_INET</b>
              The <i>name</i> argument points to a dotted-quad IPv4 address or a
              name of an IPv4 network host.

       <b>AF_INET6</b>
              The <i>name</i> argument points to a hexadecimal IPv6 address or a
              name of an IPv6 network host.

       The <i>flags</i> argument specifies additional options.  More than one
       option can be specified by bitwise OR-ing them together.  <i>flags</i>
       should be set to 0 if no options are desired.

       <b>AI_V4MAPPED</b>
              This flag is used with <b>AF_INET6 </b>to request a query for IPv4
              addresses instead of IPv6 addresses; the IPv4 addresses will
              be mapped to IPv6 addresses.

       <b>AI_ALL </b>This flag is used with <b>AI_V4MAPPED </b>to request a query for both
              IPv4 and IPv6 addresses.  Any IPv4 address found will be
              mapped to an IPv6 address.

       <b>AI_ADDRCONFIG</b>
              This flag is used with <b>AF_INET6 </b>to further request that
              queries for IPv6 addresses should not be made unless the sys‐
              tem has at least one IPv6 address assigned to a network inter‐
              face, and that queries for IPv4 addresses should not be made
              unless the system has at least one IPv4 address assigned to a
              network interface.  This flag may be used by itself or with
              the <b>AI_V4MAPPED </b>flag.

       <b>AI_DEFAULT</b>
              This flag is equivalent to <b>(AI_ADDRCONFIG | AI_V4MAPPED)</b>.

   <b>getipnodebyaddr() arguments</b>
       The <b>getipnodebyaddr</b>() function looks up the name of the host whose
       network address is specified by the <i>addr</i> argument.  The <i>af</i> argument
       specifies one of the following values:

       <b>AF_INET</b>
              The <i>addr</i> argument points to a <i>struct in_addr</i> and <i>len</i> must be
              set to <i>sizeof(struct in_addr)</i>.

       <b>AF_INET6</b>
              The <i>addr</i> argument points to a <i>struct in6_addr</i> and <i>len</i> must be
              set to <i>sizeof(struct in6_addr)</i>.
</pre>
<h2><a id="RETURN_VALUE" href="freehostent.3.html#RETURN_VALUE"></a>RETURN VALUE  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       NULL is returned if an error occurred, and <i>error_num</i> will contain an
       error code from the following list:

       <b>HOST_NOT_FOUND</b>
              The hostname or network address was not found.

       <b>NO_ADDRESS</b>
              The domain name server recognized the network address or name,
              but no answer was returned.  This can happen if the network
              host has only IPv4 addresses and a request has been made for
              IPv6 information only, or vice versa.

       <b>NO_RECOVERY</b>
              The domain name server returned a permanent failure response.

       <b>TRY_AGAIN</b>
              The domain name server returned a temporary failure response.
              You might have better luck next time.

       A successful query returns a pointer to a <i>hostent</i> structure that
       contains the following fields:

       <i>h_name</i> This is the official name of this network host.

       <i>h_aliases</i>
              This is an array of pointers to unofficial aliases for the
              same host.  The array is terminated by a null pointer.

       <i>h_addrtype</i>
              This is a copy of the <i>af</i> argument to <b>getipnodebyname</b>() or
              <b>getipnodebyaddr</b>().  <i>h_addrtype</i> will always be <b>AF_INET </b>if the
              <i>af</i> argument was <b>AF_INET</b>.  <i>h_addrtype</i> will always be <b>AF_INET6</b>
              if the <i>af</i> argument was <b>AF_INET6</b>.

       <i>h_length</i>
              This field will be set to <i>sizeof(struct in_addr)</i> if <i>h_addrtype</i>
              is <b>AF_INET</b>, and to <i>sizeof(struct in6_addr)</i> if <i>h_addrtype</i> is
              <b>AF_INET6</b>.

       <i>h_addr_list</i>
              This is an array of one or more pointers to network address
              structures for the network host.  The array is terminated by a
              null pointer.
</pre>
<h2><a id="CONFORMING_TO" href="freehostent.3.html#CONFORMING_TO"></a>CONFORMING TO  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       RFC 2553.
</pre>
<h2><a id="NOTES" href="freehostent.3.html#NOTES"></a>NOTES  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       These functions were present in glibc 2.1.91-95, but were removed
       again.  Several UNIX-like systems support them, but all call them
       deprecated.
</pre>
<h2><a id="SEE_ALSO" href="freehostent.3.html#SEE_ALSO"></a>SEE ALSO  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       <a href="getaddrinfo.3.html">getaddrinfo(3)</a>, <a href="getnameinfo.3.html">getnameinfo(3)</a>, <a href="inet_ntop.3.html">inet_ntop(3)</a>, <a href="inet_pton.3.html">inet_pton(3)</a>
</pre>
<h2><a id="COLOPHON" href="freehostent.3.html#COLOPHON"></a>COLOPHON  &nbsp; &nbsp; &nbsp; &nbsp; <a href="freehostent.3.html#top_of_page"><span class="top-link">top</span></a></h2><pre>
       This page is part of release 4.15 of the Linux <i>man-pages</i> project.  A
       description of the project, information about reporting bugs, and the
       latest version of this page, can be found at
       <a href="https://www.kernel.org/doc/man-pages/">https://www.kernel.org/doc/man-pages/</a>.

<span class="footline">Linux                            2017-09-15               GETIPNODEBYNAME(3)</span>
</pre>

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

<p class="page-copyright"><a href="getipnodebyname.3.license.html">Copyright and license for this manual page</a></p> 
<hr class="start-footer" />

<div class="footer"> 

<table class="colophon-table">
    <tr>
    <td class="pub-info">
        <p>
            HTML rendering created 2018-02-02
            by <a href="http://man7.org/mtk/index.html">Michael Kerrisk</a>, 
            author of 
            <a href="http://man7.org/tlpi/"><em>The Linux Programming 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 courses</strong>
            that I teach, look <a href="http://man7.org/training/">here</a>.
        </p>
        <p>
            Hosting by <a href="http://www.jambit.com/index_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="../../../tlpi/cover/TLPI-front-cover-vsmall.png" alt="Cover of TLPI" /></a>
    </td>
    </tr>
</table>

</div>

<hr class="end-footer" />



<!--BEGIN-SITETRACKING-->
<!-- SITETRACKING.man7.org_linux_man-pages -->

<!-- Start of StatCounter Code (xhtml) -->

<script type="text/javascript">
//<![CDATA[
var sc_project=7422636; 
var sc_invisible=1; 
var sc_security="9b6714ff"; 
//]]>
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
<noscript><div class="statcounter"><a title="website
statistics" href="http://statcounter.com/"
class="statcounter"><img class="statcounter"
src="http://c.statcounter.com/7422636/0/9b6714ff/1/"
alt="website statistics" /></a></div></noscript>

<!-- End of StatCounter Code -->


<!-- Start of Google Analytics Code -->

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-9830363-8']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

<!-- End of Google Analytics Code -->

<!--END-SITETRACKING-->

</body>
</html>
