1 .\" Copyright (c) 1983, 1987, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
33 .\" $FreeBSD: src/lib/libc/net/gethostbyname.3,v 1.12.2.6 2001/08/17 15:42:38 ru Exp $
47 .Nd get network host entry
51 .Fd #include <netdb.h>
52 .Vt extern int h_errno ;
59 .Fa "const void *addr"
65 .Fa "const char *name"
69 .Fa "const char *name"
78 .Fa "const char *string"
95 each return a pointer to an object with the
96 following structure describing an internet host
97 referenced by name or by address, respectively.
98 This structure contains either the information obtained from the name server,
100 or broken-out fields from a line in
102 If the local name server is not running these routines do a lookup in
106 char *h_name; /* official name of host */
107 char **h_aliases; /* alias list */
108 int h_addrtype; /* host address type */
109 int h_length; /* length of address */
110 char **h_addr_list; /* list of addresses from name server */
112 #define h_addr h_addr_list[0] /* address, for backward compatibility */
115 The members of this structure are:
116 .Bl -tag -width h_addr_list
118 Official name of the host.
121 .Dv NULL Ns -terminated
122 array of alternate names for the host.
124 The type of address being returned; usually
127 The length, in bytes, of the address.
130 .Dv NULL Ns -terminated
131 array of network addresses for the host.
132 Host addresses are returned in network byte order.
136 this is for backward compatibility.
139 When using the nameserver,
143 will search for the named host in the current domain and its parents
144 unless the name ends in a dot.
145 If the name contains no dot, and if the environment variable
147 contains the name of an alias file, the alias file will first be searched
148 for an alias matching the input name.
151 for the domain search procedure and the alias file format.
155 function is an evolution of
157 which is intended to allow lookups in address families other than
161 Both of these address families are supported in the Mac OS X implemention.
166 may be used to request the use of a connected
172 this sets the option to send all queries to the name server using
174 and to retain the connection after each call to
179 Otherwise, queries are performed using
192 function writes a message to the diagnostic output consisting of the
197 and a message corresponding to the value of
202 function returns a string which is the message text corresponding to the
207 .Bl -tag -width /etc/resolv.conf -compact
209 .It Pa /etc/host.conf
210 .It Pa /etc/resolv.conf
213 Error return status from
218 is indicated by return of a
223 may then be checked to see whether this is a temporary failure
224 or an invalid or unknown host.
227 can be used to print an error message describing the failure.
232 it is printed, followed by a colon and a space.
233 The error message is printed with a trailing newline.
237 can have the following values:
238 .Bl -tag -width HOST_NOT_FOUND
239 .It Dv HOST_NOT_FOUND
240 No such host is known.
242 This is usually a temporary error
243 and means that the local server did not receive
244 a response from an authoritative server.
245 A retry at some later time may succeed.
247 Some unexpected server failure was encountered.
248 This is a non-recoverable error.
250 The requested name is valid but does not have an IP address;
251 this is not a temporary error.
252 This means that the name is known to the name server but there is no address
253 associated with this name.
254 Another type of request to the name server using this domain name
255 will result in an answer;
256 for example, a mail-forwarder may be registered for this domain.
259 .Fd #include <netdb.h>
261 .Vt extern int h_errno ;
266 .Fa "const void *addr"
273 has changed slightly.
289 when libc is built to use only the routines to lookup in
291 and not the name server.
296 reads the next line of
298 opening the file if necessary.
303 opens and/or rewinds the file
307 argument is non-zero,
308 the file will not be closed after each call to
330 functions appeared in
334 function first appeared in
338 These functions use static data storage;
339 if the data is needed for future use, it should be
340 copied before any subsequent calls overwrite it.
342 address format is currently understood.