1GETHOSTBYADDR(3P) POSIX Programmer's Manual GETHOSTBYADDR(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 gethostbyaddr, gethostbyname - network host database functions
13
15 #include <netdb.h>
16
17
18
19 struct hostent *gethostbyaddr(const void *addr, socklen_t len,
20 int type);
21 struct hostent *gethostbyname(const char *name);
22
23
25 These functions shall retrieve information about hosts. This informa‐
26 tion is considered to be stored in a database that can be accessed
27 sequentially or randomly. Implementation of this database is unspeci‐
28 fied.
29
30 Note: In many cases it is implemented by the Domain Name System, as
31 documented in RFC 1034, RFC 1035, and RFC 1886.
32
33
34 Entries shall be returned in hostent structures.
35
36 The gethostbyaddr() function shall return an entry containing addresses
37 of address family type for the host with address addr. The len argument
38 contains the length of the address pointed to by addr. The gethost‐
39 byaddr() function need not be reentrant. A function that is not
40 required to be reentrant is not required to be thread-safe.
41
42 The gethostbyname() function shall return an entry containing addresses
43 of address family AF_INET for the host with name name. The gethostby‐
44 name() function need not be reentrant. A function that is not required
45 to be reentrant is not required to be thread-safe.
46
47 The addr argument of gethostbyaddr() shall be an in_addr structure when
48 type is AF_INET. It contains a binary format (that is, not null-termi‐
49 nated) address in network byte order. The gethostbyaddr() function is
50 not guaranteed to return addresses of address families other than
51 AF_INET, even when such addresses exist in the database.
52
53 If gethostbyaddr() returns successfully, then the h_addrtype field in
54 the result shall be the same as the type argument that was passed to
55 the function, and the h_addr_list field shall list a single address
56 that is a copy of the addr argument that was passed to the function.
57
58 The name argument of gethostbyname() shall be a node name; the behavior
59 of gethostbyname() when passed a numeric address string is unspecified.
60 For IPv4, a numeric address string shall be in the dotted-decimal nota‐
61 tion described in inet_addr() .
62
63 If name is not a numeric address string and is an alias for a valid
64 host name, then gethostbyname() shall return information about the host
65 name to which the alias refers, and name shall be included in the list
66 of aliases returned.
67
69 Upon successful completion, these functions shall return a pointer to a
70 hostent structure if the requested entry was found, and a null pointer
71 if the end of the database was reached or the requested entry was not
72 found.
73
74 Upon unsuccessful completion, gethostbyaddr() and gethostbyname() shall
75 set h_errno to indicate the error.
76
78 These functions shall fail in the following cases. The gethostbyaddr()
79 and gethostbyname() functions shall set h_errno to the value shown in
80 the list below. Any changes to errno are unspecified.
81
82 HOST_NOT_FOUND
83
84 No such host is known.
85
86 NO_DATA
87 The server recognized the request and the name, but no address
88 is available. Another type of request to the name server for the
89 domain might return an answer.
90
91 NO_RECOVERY
92
93 An unexpected server failure occurred which cannot be recovered.
94
95 TRY_AGAIN
96 A temporary and possibly transient error occurred, such as a
97 failure of a server to respond.
98
99
100 The following sections are informative.
101
103 None.
104
106 The gethostbyaddr() and gethostbyname() functions may return pointers
107 to static data, which may be overwritten by subsequent calls to any of
108 these functions.
109
110 The getaddrinfo() and getnameinfo() functions are preferred over the
111 gethostbyaddr() and gethostbyname() functions.
112
114 None.
115
117 The gethostbyaddr() and gethostbyname() functions may be withdrawn in a
118 future version.
119
121 endhostent(), endservent(), gai_strerror(), getaddrinfo(), h_errno(),
122 inet_addr(), the Base Definitions volume of IEEE Std 1003.1-2001,
123 <netdb.h>
124
126 Portions of this text are reprinted and reproduced in electronic form
127 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
128 -- Portable Operating System Interface (POSIX), The Open Group Base
129 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
130 Electrical and Electronics Engineers, Inc and The Open Group. In the
131 event of any discrepancy between this version and the original IEEE and
132 The Open Group Standard, the original IEEE and The Open Group Standard
133 is the referee document. The original Standard can be obtained online
134 at http://www.opengroup.org/unix/online.html .
135
136
137
138IEEE/The Open Group 2003 GETHOSTBYADDR(3P)