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 2021-03-22 "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 );
38 .BI "struct hostent *getipnodebyaddr(const void *" addr ", size_t " len ,
39 .BI " int " af ", int *" "error_num" );
40 .BI "void freehostent(struct hostent *" "ip" );
43 These functions are deprecated (and unavailable in glibc).
51 .BR getipnodebyname ()
53 .BR getipnodebyaddr ()
54 functions return the names and addresses of a network host.
55 These functions return a pointer to the
70 These functions replace the
74 functions, which could access only the IPv4 network address family.
76 .BR getipnodebyname ()
78 .BR getipnodebyaddr ()
79 functions can access multiple network address families.
84 these functions return pointers to dynamically allocated memory.
87 function is used to release the dynamically allocated memory
88 after the caller no longer needs the
91 .SS getipnodebyname() arguments
93 .BR getipnodebyname ()
95 looks up network addresses for the host
101 argument specifies one of the following values:
106 argument points to a dotted-quad IPv4 address or a name
107 of an IPv4 network host.
112 argument points to a hexadecimal IPv6 address or a name
113 of an IPv6 network host.
117 argument specifies additional options.
118 More than one option can be specified by bitwise OR-ing
122 if no options are desired.
125 This flag is used with
127 to request a query for IPv4 addresses instead of
128 IPv6 addresses; the IPv4 addresses will
129 be mapped to IPv6 addresses.
132 This flag is used with
134 to request a query for both IPv4 and IPv6 addresses.
135 Any IPv4 address found will be mapped to an IPv6 address.
138 This flag is used with
141 further request that queries for IPv6 addresses should not be made unless
142 the system has at least one IPv6 address assigned to a network interface,
143 and that queries for IPv4 addresses should not be made unless the
144 system has at least one IPv4 address assigned to a network interface.
145 This flag may be used by itself or with the
150 This flag is equivalent to
151 .BR "(AI_ADDRCONFIG | AI_V4MAPPED)" .
152 .SS getipnodebyaddr() arguments
154 .BR getipnodebyaddr ()
156 looks up the name of the host whose
163 argument specifies one of the following values:
173 .IR "sizeof(struct in_addr)" .
183 .IR "sizeof(struct in6_addr)" .
185 NULL is returned if an error occurred, and
187 will contain an error code from the following list:
190 The hostname or network address was not found.
193 The domain name server recognized the network address or name,
194 but no answer was returned.
195 This can happen if the network host has only IPv4 addresses and
196 a request has been made for IPv6 information only, or vice versa.
199 The domain name server returned a permanent failure response.
202 The domain name server returned a temporary failure response.
203 You might have better luck next time.
205 A successful query returns a pointer to a
207 structure that contains the following fields:
210 This is the official name of this network host.
213 This is an array of pointers to unofficial aliases for the same host.
214 The array is terminated by a null pointer.
217 This is a copy of the
220 .BR getipnodebyname ()
222 .BR getipnodebyaddr ().
239 This field will be set to
240 .I sizeof(struct in_addr)
246 .I sizeof(struct in6_addr)
253 This is an array of one or more pointers to network address structures for the
255 The array is terminated by a null pointer.
258 .\" Not in POSIX.1-2001.
260 These functions were present in glibc 2.1.91-95, but were
262 Several UNIX-like systems support them, but all
263 call them deprecated.