399 lines
8.1 KiB
HTML
399 lines
8.1 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of GETIPNODEBYNAME</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>GETIPNODEBYNAME</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
getipnodebyname, getipnodebyaddr, freehostent - get network
|
|
hostnames and addresses
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/sys/socket.h">sys/socket.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/netdb.h">netdb.h</A>></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>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
These functions are deprecated (and unavailable in glibc).
|
|
Use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getaddrinfo">getaddrinfo</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getnameinfo">getnameinfo</A></B>(3)
|
|
|
|
instead.
|
|
<P>
|
|
|
|
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:
|
|
<P>
|
|
|
|
|
|
|
|
struct hostent {
|
|
<BR> char *h_name;
|
|
<BR> char **h_aliases;
|
|
<BR> int h_addrtype;
|
|
<BR> int h_length;
|
|
<BR> char **h_addr_list;
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
These functions replace the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+gethostbyname">gethostbyname</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+gethostbyaddr">gethostbyaddr</A></B>(3)
|
|
|
|
functions, which could access only the IPv4 network address family.
|
|
The
|
|
<B>getipnodebyname</B>()
|
|
|
|
and
|
|
<B>getipnodebyaddr</B>()
|
|
|
|
functions can access multiple network address families.
|
|
<P>
|
|
|
|
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.
|
|
<A NAME="lbAE"> </A>
|
|
<H3>getipnodebyname() arguments</H3>
|
|
|
|
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:
|
|
<DL COMPACT>
|
|
<DT id="1"><B>AF_INET</B>
|
|
|
|
<DD>
|
|
The
|
|
<I>name</I>
|
|
|
|
argument points to a dotted-quad IPv4 address or a name
|
|
of an IPv4 network host.
|
|
<DT id="2"><B>AF_INET6</B>
|
|
|
|
<DD>
|
|
The
|
|
<I>name</I>
|
|
|
|
argument points to a hexadecimal IPv6 address or a name
|
|
of an IPv6 network host.
|
|
</DL>
|
|
<P>
|
|
|
|
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.
|
|
<DL COMPACT>
|
|
<DT id="3"><B>AI_V4MAPPED</B>
|
|
|
|
<DD>
|
|
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.
|
|
<DT id="4"><B>AI_ALL</B>
|
|
|
|
<DD>
|
|
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.
|
|
<DT id="5"><B>AI_ADDRCONFIG</B>
|
|
|
|
<DD>
|
|
This flag is used with
|
|
<B>AF_INET6</B>
|
|
|
|
to
|
|
further request that queries for IPv6 addresses should not be made unless
|
|
the system has at least one IPv6 address assigned to a network interface,
|
|
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.
|
|
<DT id="6"><B>AI_DEFAULT</B>
|
|
|
|
<DD>
|
|
This flag is equivalent to
|
|
<B>(AI_ADDRCONFIG | AI_V4MAPPED)</B>.
|
|
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H3>getipnodebyaddr() arguments</H3>
|
|
|
|
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:
|
|
<DL COMPACT>
|
|
<DT id="7"><B>AF_INET</B>
|
|
|
|
<DD>
|
|
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>.
|
|
|
|
<DT id="8"><B>AF_INET6</B>
|
|
|
|
<DD>
|
|
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>.
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
NULL is returned if an error occurred, and
|
|
<I>error_num</I>
|
|
|
|
will contain an error code from the following list:
|
|
<DL COMPACT>
|
|
<DT id="9"><B>HOST_NOT_FOUND</B>
|
|
|
|
<DD>
|
|
The hostname or network address was not found.
|
|
<DT id="10"><B>NO_ADDRESS</B>
|
|
|
|
<DD>
|
|
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.
|
|
<DT id="11"><B>NO_RECOVERY</B>
|
|
|
|
<DD>
|
|
The domain name server returned a permanent failure response.
|
|
<DT id="12"><B>TRY_AGAIN</B>
|
|
|
|
<DD>
|
|
The domain name server returned a temporary failure response.
|
|
You might have better luck next time.
|
|
</DL>
|
|
<P>
|
|
|
|
A successful query returns a pointer to a
|
|
<I>hostent</I>
|
|
|
|
structure that contains the following fields:
|
|
<DL COMPACT>
|
|
<DT id="13"><I>h_name</I>
|
|
|
|
<DD>
|
|
This is the official name of this network host.
|
|
<DT id="14"><I>h_aliases</I>
|
|
|
|
<DD>
|
|
This is an array of pointers to unofficial aliases for the same host.
|
|
The array is terminated by a null pointer.
|
|
<DT id="15"><I>h_addrtype</I>
|
|
|
|
<DD>
|
|
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>.
|
|
|
|
<DT id="16"><I>h_length</I>
|
|
|
|
<DD>
|
|
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>.
|
|
|
|
<DT id="17"><I>h_addr_list</I>
|
|
|
|
<DD>
|
|
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.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
RFC 2553.
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
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.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getaddrinfo">getaddrinfo</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getnameinfo">getnameinfo</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet_ntop">inet_ntop</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet_pton">inet_pton</A></B>(3)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 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>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="18"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="19"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="20"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="21"><A HREF="#lbAE">getipnodebyname() arguments</A><DD>
|
|
<DT id="22"><A HREF="#lbAF">getipnodebyaddr() arguments</A><DD>
|
|
</DL>
|
|
<DT id="23"><A HREF="#lbAG">RETURN VALUE</A><DD>
|
|
<DT id="24"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="25"><A HREF="#lbAI">NOTES</A><DD>
|
|
<DT id="26"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="27"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:44 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|