1 .\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References: RFC 2553
26 .TH GETIPNODEBYNAME 3 2017-09-15 "Linux" "Linux Programmer's Manual"
28 getipnodebyname, getipnodebyaddr, freehostent \- get network
29 hostnames and addresses
32 .B #include <sys/types.h>
33 .B #include <sys/socket.h>
36 .BI "struct hostent *getipnodebyname(const char *" name ", int " af ,
37 .BI " int " flags ", int *" error_num );
39 .BI "struct hostent *getipnodebyaddr(const void *" addr ", size_t " len ,
40 .BI " int " af ", int *" "error_num" );
42 .BI "void freehostent(struct hostent *" "ip" );
45 These functions are deprecated (and unavailable in glibc).
53 .BR getipnodebyname ()
55 .BR getipnodebyaddr ()
56 functions return the names and addresses of a network host.
57 These functions return a pointer to the
72 These functions replace the
76 functions, which could access only the IPv4 network address family.
78 .BR getipnodebyname ()
80 .BR getipnodebyaddr ()
81 functions can access multiple network address families.
86 these functions return pointers to dynamically allocated memory.
89 function is used to release the dynamically allocated memory
90 after the caller no longer needs the
93 .SS getipnodebyname() arguments
95 .BR getipnodebyname ()
97 looks up network addresses for the host
103 argument specifies one of the following values:
108 argument points to a dotted-quad IPv4 address or a name
109 of an IPv4 network host.
114 argument points to a hexadecimal IPv6 address or a name
115 of an IPv6 network host.
119 argument specifies additional options.
120 More than one option can be specified by bitwise OR-ing
124 if no options are desired.
127 This flag is used with
129 to request a query for IPv4 addresses instead of
130 IPv6 addresses; the IPv4 addresses will
131 be mapped to IPv6 addresses.
134 This flag is used with
136 to request a query for both IPv4 and IPv6 addresses.
137 Any IPv4 address found will be mapped to an IPv6 address.
140 This flag is used with
143 further request that queries for IPv6 addresses should not be made unless
144 the system has at least one IPv6 address assigned to a network interface,
145 and that queries for IPv4 addresses should not be made unless the
146 system has at least one IPv4 address assigned to a network interface.
147 This flag may be used by itself or with the
152 This flag is equivalent to
153 .BR "(AI_ADDRCONFIG | AI_V4MAPPED)" .
154 .SS getipnodebyaddr() arguments
156 .BR getipnodebyaddr ()
158 looks up the name of the host whose
165 argument specifies one of the following values:
175 .IR "sizeof(struct in_addr)" .
185 .IR "sizeof(struct in6_addr)" .
187 NULL is returned if an error occurred, and
189 will contain an error code from the following list:
192 The hostname or network address was not found.
195 The domain name server recognized the network address or name,
196 but no answer was returned.
197 This can happen if the network host has only IPv4 addresses and
198 a request has been made for IPv6 information only, or vice versa.
201 The domain name server returned a permanent failure response.
204 The domain name server returned a temporary failure response.
205 You might have better luck next time.
207 A successful query returns a pointer to a
209 structure that contains the following fields:
212 This is the official name of this network host.
215 This is an array of pointers to unofficial aliases for the same host.
216 The array is terminated by a null pointer.
219 This is a copy of the
222 .BR getipnodebyname ()
224 .BR getipnodebyaddr ().
241 This field will be set to
242 .I sizeof(struct in_addr)
248 .I sizeof(struct in6_addr)
255 This is an array of one or more pointers to network address structures for the
257 The array is terminated by a null pointer.
260 .\" Not in POSIX.1-2001.
262 These functions were present in glibc 2.1.91-95, but were
264 Several UNIX-like systems support them, but all
265 call them deprecated.