1 .\" Copyright (c) 1983, 1987 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms are permitted provided
5 .\" that: (1) source distributions retain this entire copyright notice and
6 .\" comment, and (2) distributions including binaries display the following
7 .\" acknowledgement: ``This product includes software developed by the
8 .\" University of California, Berkeley and its contributors'' in the
9 .\" documentation or other materials provided with the distribution and in
10 .\" all advertising materials mentioning features or use of this software.
11 .\" Neither the name of the University nor the names of its contributors may
12 .\" be used to endorse or promote products derived from this software without
13 .\" specific prior written permission.
14 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 .\" @(#)gethostbyname.3 6.12 (Berkeley) 6/23/90
20 .TH GETHOSTBYNAME 3 "June 23, 1990"
23 g_h_b_n, gethostbyname, gethostbyaddr, gethostent, sethostent, endhostent, herror \- get network host entry
25 .B "#include <net/gen/netdb.h>
27 .B "extern int h_errno;
29 .B "struct hostent *gethostbyname(name)
33 .B "struct hostent *gethostbyaddr(addr, len, type)
35 .B "char *addr; int len, type;
37 .B "struct hostent *gethostent()
39 .B "sethostent(stayopen)
53 each return a pointer to an object with the
54 following structure describing an internet host
55 referenced by name or by address, respectively.
56 This structure contains the information obtained from the name server.
60 char *h_name; /* official name of host */
61 char **h_aliases; /* alias list */
62 int h_addrtype; /* host address type */
63 int h_length; /* length of address */
64 char **h_addr_list; /* list of addresses from name server */
66 #define h_addr h_addr_list[0] /* address, for backward compatibility */
71 The members of this structure are:
72 .TP \w'h_addr_list'u+2n
74 Official name of the host.
75 .TP \w'h_addr_list'u+2n
77 A zero terminated array of alternate names for the host.
78 .TP \w'h_addr_list'u+2n
80 The type of address being returned; currently always AF_INET.
81 .TP \w'h_addr_list'u+2n
83 The length, in bytes, of the address.
84 .TP \w'h_addr_list'u+2n
86 A zero terminated array of network addresses for the host.
87 Host addresses are returned in network byte order.
88 .TP \w'h_addr_list'u+2n
90 The first address in h_addr_list; this is for backward compatiblity.
92 When using the nameserver,
94 will search for the named host in the current domain and its parents
95 unless the name ends in a dot.
96 If the name contains no dot, and if the environment variable ``HOSTALAIASES''
97 contains the name of an alias file, the alias file will first be searched
98 for an alias matching the input name.
101 for the domain search procedure and the alias file format.
104 may be used to request the use of a connected TCP socket for queries.
108 this sets the option to send all queries to the name server using TCP
109 and to retain the connection after each call to
113 Otherwise, queries are performed using UDP datagrams.
116 closes the TCP connection.
119 Error return status from
123 is indicated by return of a null pointer.
126 may then be checked to see whether this is a temporary failure
127 or an invalid or unknown host.
130 can be used to print an error message describing the failure.
133 is non-NULL, it is printed, followed by a colon and a space.
134 The error message is printed with a trailing newline.
137 can have the following values:
139 .IP HOST_NOT_FOUND \w'HOST_NOT_FOUND'u+2n
140 No such host is known.
141 .IP TRY_AGAIN \w'HOST_NOT_FOUND'u+2n
142 This is usually a temporary error
143 and means that the local server did not receive
144 a response from an authoritative server.
145 A retry at some later time may succeed.
146 .IP NO_RECOVERY \w'HOST_NOT_FOUND'u+2n
147 Some unexpected server failure was encountered.
148 This is a non-recoverable error.
149 .IP NO_DATA \w'HOST_NOT_FOUND'u+2n
150 The requested name is valid but does not have an IP address;
151 this is not a temporary error.
152 This means that the name is known to the name server but there is no address
153 associated with this name.
154 Another type of request to the name server using this domain name
155 will result in an answer;
156 for example, a mail-forwarder may be registered for this domain.
159 resolver(3), hostname(7), nonamed(8), named(8)
162 is contained in a static area
163 so it must be copied if it is
164 to be saved. Only the Internet
165 address format is currently understood.