OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[linuxjm/LDP_man-pages.git] / draft / man3 / gethostbyname.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified 1993-05-22, David Metcalfe
28 .\" Modified 1993-07-25, Rik Faith (faith@cs.unc.edu)
29 .\" Modified 1997-02-16, Andries Brouwer (aeb@cwi.nl)
30 .\" Modified 1998-12-21, Andries Brouwer (aeb@cwi.nl)
31 .\" Modified 2000-08-12, Andries Brouwer (aeb@cwi.nl)
32 .\" Modified 2001-05-19, Andries Brouwer (aeb@cwi.nl)
33 .\" Modified 2002-08-05, Michael Kerrisk
34 .\" Modified 2004-10-31, Andries Brouwer
35 .\"
36 .\" Japanese Version Copyright (c) 1998-2000 NAKANO Takeo all rights reserved.
37 .\" Translated 1998-04-30, NAKANO Takeo <nakano@apm.seikei.ac.jp>
38 .\" Modified 1998-12-06, NAKANO Takeo
39 .\" Updated & Modified 1999-10-12, NAKANO Takeo
40 .\" Updated & Modified 2001-07-01, Yuichi SATO <ysato@h4.dion.ne.jp>
41 .\" Updated & Modified 2002-01-03, Yuichi SATO
42 .\" Updated & Modified 2003-11-27, Yuichi SATO <ysato444@yahoo.co.jp>
43 .\" Updated & Modified 2005-01-10, Yuichi SATO
44 .\" Updated 2006-01-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2007-06-11, Akihiro MOTOKI, LDP v2.54
46 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
47 .\"
48 .TH GETHOSTBYNAME 3 2010-10-04 "" "Linux Programmer's Manual"
49 .\"O .SH NAME
50 .\"O gethostbyname, gethostbyaddr, sethostent, gethostent, endhostent,
51 .\"O h_errno,
52 .\"O herror, hstrerror,
53 .\"O gethostbyaddr_r,
54 .\"O gethostbyname2, gethostbyname2_r, gethostbyname_r,
55 .\"O gethostent_r \- get network host entry
56 .SH Ì¾Á°
57 gethostbyname, gethostbyaddr, sethostent, gethostent, endhostent,
58 h_errno,
59 herror, hstrerror,
60 gethostbyaddr_r,
61 gethostbyname2, gethostbyname2_r, gethostbyname_r,
62 gethostent_r \- ¥Í¥Ã¥È¥ï¡¼¥¯¾å¤Î¥Û¥¹¥È¤Î¥¨¥ó¥È¥ê¤ò¼èÆÀ¤¹¤ë
63 .\"O .SH SYNOPSIS
64 .SH ½ñ¼°
65 .nf
66 .B #include <netdb.h>
67 .B extern int h_errno;
68 .sp
69 .BI "struct hostent *gethostbyname(const char *" name );
70 .sp
71 .\"O .BR "#include <sys/socket.h>" "       /* for AF_INET */"
72 .BR "#include <sys/socket.h>" "       /* AF_INET ¤ò»È¤¦¾ì¹ç */"
73 .BI "struct hostent *gethostbyaddr(const void *" addr ,
74 .BI "                              socklen_t " len ", int " type );
75 .sp
76 .BI "void sethostent(int " stayopen );
77 .sp
78 .B void endhostent(void);
79 .sp
80 .BI "void herror(const char *" s );
81 .sp
82 .BI "const char *hstrerror(int " err );
83 .sp
84 .\"O /* System V/POSIX extension */
85 /* System V/POSIX ³ÈÄ¥ */
86 .br
87 .B struct hostent *gethostent(void);
88 .sp
89 .\"O /* GNU extensions */
90 /* GNU ³ÈÄ¥ */
91 .br
92 .BI "struct hostent *gethostbyname2(const char *" name ", int " af );
93 .sp
94 .B "int gethostent_r("
95 .BI "        struct hostent *" ret ", char *" buf ", size_t " buflen ,
96 .BI "        struct hostent **" result ", int *" h_errnop );
97 .sp
98 .BI "int gethostbyaddr_r(const void *" addr ", socklen_t " len ", int " type ,
99 .BI "        struct hostent *" ret ", char *" buf ", size_t " buflen ,
100 .BI "        struct hostent **" result ", int *" h_errnop );
101 .sp
102 .BI "int gethostbyname_r(const char *" name ,
103 .BI "        struct hostent *" ret ", char *" buf ", size_t " buflen ,
104 .BI "        struct hostent **" result ", int *" h_errnop );
105 .sp
106 .BI "int gethostbyname2_r(const char *" name ", int " af,
107 .BI "        struct hostent *" ret ", char *" buf ", size_t " buflen ,
108 .BI "        struct hostent **" result ", int *" h_errnop );
109 .fi
110 .sp
111 .in -4n
112 .\"O Feature Test Macro Requirements for glibc (see
113 .\"O .BR feature_test_macros (7)):
114 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
115 .RB ( feature_test_macros (7)
116 »²¾È):
117 .in
118 .sp
119 .PD 0
120 .ad l
121 .BR gethostbyname2 (),
122 .BR gethostent_r (),
123 .BR gethostbyaddr_r (),
124 .BR gethostbyname_r (),
125 .BR gethostbyname2_r ():
126 .RS 4
127 _BSD_SOURCE || _SVID_SOURCE
128 .RE
129
130 .BR herror (),
131 .BR hstrerror ():
132 .RS 4
133 .TP 4
134 .\"O Since glibc 2.8:
135 glibc 2.8 °Ê¹ß:
136 _BSD_SOURCE || _SVID_SOURCE || _GNU_SOURCE
137 .TP
138 .\"O Before glibc 2.8:
139 .\"O none
140 glibc 2.8 ¤è¤êÁ°:
141 ¤Ê¤·
142 .RE
143 .ad b
144 .PD
145 .\"O .SH DESCRIPTION
146 .SH ÀâÌÀ
147 .\"O The
148 .\"O .BR gethostbyname* ()
149 .\"O and
150 .\"O .BR gethostbyaddr* ()
151 .\"O functions are obsolete.
152 .\"O Applications should use
153 .\"O .BR getaddrinfo (3)
154 .\"O and
155 .\"O .BR getnameinfo (3)
156 .\"O instead.
157 .BR gethostbyname* ()
158 ¤È
159 .BR gethostbyaddr* ()
160 ¤Ï²áµî¤Î¤â¤Î¤Ç¤¢¤ë¡£
161 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢Âå¤ï¤ê¤Ë
162 .BR getaddrinfo (3)
163 ¤È
164 .BR getnameinfo (3)
165 ¤ò»ÈÍѤ¹¤ë¤³¤È¡£
166
167 .\"O The
168 .\"O .BR gethostbyname ()
169 .\"O function returns a structure of type
170 .\"O .I hostent
171 .\"O for the given host
172 .\"O .IR name .
173 .\"O Here
174 .\"O .I name
175 .\"O is either a hostname, or an IPv4 address in standard dot notation (as for
176 .\"O .BR inet_addr (3)),
177 .\"O or an IPv6 address in colon (and possibly dot) notation.
178 .\"O (See RFC\ 1884 for the description of IPv6 addresses.)
179 .BR gethostbyname ()
180 ´Ø¿ô¤ÏÍ¿¤¨¤é¤ì¤¿¥Û¥¹¥È̾
181 .I name
182 ¤ËÂбþ¤¹¤ë¹½Â¤ÂÎ
183 .I hostent
184 ¤òÊÖ¤¹¡£
185 .I name
186 ¤Ë¤Ï¥Û¥¹¥È̾¡¢¥É¥Ã¥È¶èÀÚ¤ê¤Î IPv4 ¥¢¥É¥ì¥¹
187 .RB ( inet_addr (3)
188 »²¾È)¡¢¥³¥í¥ó¶èÀÚ¤ê¤Î IPv6 ¥¢¥É¥ì¥¹ (¤ª¤½¤é¤¯¥É¥Ã¥È¶èÀÚ¤ê¤Ç¤âÂç¾æÉ×)
189 ¤Î¤¤¤º¤ì¤«¤ò»ØÄꤹ¤ë
190 (IPv6 ¥¢¥É¥ì¥¹¤Îµ­½ÒÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï RFC\ 1884 ¤ò»²¹Í¤Ë¤·¤Æ¤Û¤·¤¤)¡£
191 .\"O If
192 .\"O .I name
193 .\"O is an IPv4 or IPv6 address, no lookup is performed and
194 .\"O .BR gethostbyname ()
195 .\"O simply copies
196 .\"O .I name
197 .\"O into the
198 .\"O .I h_name
199 .\"O field and its
200 .\"O .I struct in_addr
201 .\"O equivalent into the
202 .\"O .I h_addr_list[0]
203 .\"O field of the returned
204 .\"O .I hostent
205 .\"O structure.
206 .I name
207 ¤¬ IPv4 ¤« IPv6 ¤Î¥¢¥É¥ì¥¹¤À¤Ã¤¿¾ì¹ç¡¢
208 ̾Á°²ò·è (lookup) ¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£¤½¤Î¾ì¹ç¤Ë¤Ï¡¢
209 .BR gethostbyname ()
210 ¤Ï
211 .I name
212 ¤ò¤½¤Î¤Þ¤Þ
213 .I hostent
214 ¹½Â¤ÂΤÎ
215 .I h_name
216 ¥Õ¥£¡¼¥ë¥É¤Ë¥³¥Ô¡¼¤·¡¢
217 ¤µ¤é¤Ë
218 .I name
219 ¤ò
220 .I struct in_addr
221 ·Á¼°¤Çɽ¤·¤¿¥Ç¡¼¥¿¤ò
222 .I hostent
223 ¹½Â¤ÂΤÎ
224 .I h_addr_list[0]
225 ¥Õ¥£¡¼¥ë¥É¤ËÆþ¤ì¤Æ¡¢¤½¤Î
226 .I hostent
227 ¹½Â¤ÂΤòÊÖ¤¹¡£
228 .\"O If
229 .\"O .I name
230 .\"O doesn't end in a dot and the environment variable
231 .\"O .B HOSTALIASES
232 .\"O is set, the alias file pointed to by
233 .\"O .B HOSTALIASES
234 .\"O will first be searched for
235 .\"O .I name
236 .\"O (see
237 .\"O .BR hostname (7)
238 .\"O for the file format).
239 .I name
240 ¤¬¥É¥Ã¥È¤Ç½ªÎ»¤·¤Æ¤¤¤Æ¡¢¤«¤Ä´Ä¶­ÊÑ¿ô
241 .B HOSTALIASES
242 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¤Þ¤º
243 .B HOSTALIASES
244 ¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë¥¨¥¤¥ê¥¢¥¹¥Õ¥¡¥¤¥ë¤«¤é
245 .I name
246 ¤Î¥¨¥ó¥È¥ê¤¬¸¡º÷¤µ¤ì¤ë (¥Õ¥¡¥¤¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ë¤Ä¤¤¤Æ¤Ï
247 .BR hostname (7)
248 ¤ò»²¾È¤Î¤³¤È)¡£
249 .\"O The current domain and its parents are searched unless \fIname\fP
250 .\"O ends in a dot.
251 .I name
252 ¤¬¥É¥Ã¥È¤Ç½ªÎ»¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¸½ºß¤Î¥É¥á¥¤¥ó¤È¤½¤Î¿Æ¥É¥á¥¤¥ó¤¬¸¡º÷¤µ¤ì¤ë¡£
253 .PP
254 .\"O The
255 .\"O .BR gethostbyaddr ()
256 .\"O function returns a structure of type \fIhostent\fP
257 .\"O for the given host address \fIaddr\fP of length \fIlen\fP and address type
258 .\"O \fItype\fP.
259 .\"O Valid address types are
260 .\"O .B AF_INET
261 .\"O and
262 .\"O .BR AF_INET6 .
263 .BR gethostbyaddr ()
264 ´Ø¿ô¤ÏÍ¿¤¨¤é¤ì¤¿¥Û¥¹¥È¥¢¥É¥ì¥¹
265 .I addr
266 (Ťµ \fIlen\fP¡¢ ¥¿¥¤¥× \fItype\fP) ¤ËÂбþ¤¹¤ë¹½Â¤ÂÎ
267 .I hostent
268 ¤òÊÖ¤¹¡£
269 ÍѤ¤¤ë¤³¤È¤Î¤Ç¤­¤ë¥¿¥¤¥×¤Ï
270 .B AF_INET
271 ¤È
272 .B AF_INET6
273 ¤Ç¤¢¤ë¡£
274 .\"O The host address argument is a pointer to a struct of a type depending
275 .\"O on the address type, for example a \fIstruct in_addr *\fP (probably
276 .\"O obtained via a call to
277 .\"O .BR inet_addr (3))
278 .\"O for address type
279 .\"O .BR AF_INET .
280 ¥Û¥¹¥È¥¢¥É¥ì¥¹°ú¤­¿ô¤Ï¥¢¥É¥ì¥¹¥¿¥¤¥×¤Ë°Í¸¤·¤¿
281 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤Ç¤¢¤ë¡£
282 Î㤨¤Ð¡¢¥¢¥É¥ì¥¹¥¿¥¤¥×
283 .B AF_INET
284 ¤ËÂФ·¤Æ¤Ï
285 .RB ( inet_addr (3)
286 ¤Î¸Æ¤Ó½Ð¤·¤ÇÆÀ¤é¤ì¤ë)
287 \fIstruct in_addr *\fP ¤Ç¤¢¤ë¡£
288 .PP
289 .\"O The
290 .\"O .BR sethostent ()
291 .\"O function specifies, if \fIstayopen\fP is true (1),
292 .\"O that a connected TCP socket should be used for the name server queries and
293 .\"O that the connection should remain open during successive queries.
294 .\"O Otherwise, name server queries will use UDP datagrams.
295 .BR sethostent ()
296 ´Ø¿ô¤Ï¡¢¥Í¡¼¥à¥µ¡¼¥Ð¤Ø¤ÎÀܳ·ÁÂÖ¤ò»ØÄꤹ¤ë¡£
297 .I stayopen
298 ¤¬¿¿ (1) ¤Ê¤é¤Ð¡¢¥Í¡¼¥à¥µ¡¼¥Ð¤Ø¤ÎÌ䤤¹ç¤ï¤»¤Ë¤Ï¡¢
299 Àܳ¤µ¤ì¤¿ TCP ¥½¥±¥Ã¥È¤òÍѤ¤¡¢Ï¢Â³¤·¤¿Ì䤤¹ç¤ï¤»¤Î´Ö¤ËÀܳ¤ò°Ý»ý¤¹¤ë¡£
300 µ¶¤Ê¤é¤Ð¥Í¡¼¥à¥µ¡¼¥Ð¤Ø¤ÎÌ䤤¹ç¤ï¤»¤Ë UDP ¥Ç¡¼¥¿¥°¥é¥à¤òÍѤ¤¤ë¡£
301 .PP
302 .\"O The
303 .\"O .BR endhostent ()
304 .\"O function ends the use of a TCP connection for name
305 .\"O server queries.
306 .BR endhostent ()
307 ´Ø¿ô¤Ï¥Í¡¼¥à¥µ¡¼¥Ð¤Ø¤ÎÌ䤤¹ç¤ï¤»¤ËÍѤ¤¤¿ TCP Àܳ¤ÎÍøÍѤò½ªÎ»¤¹¤ë¡£
308 .PP
309 .\"O The (obsolete)
310 .\"O .BR herror ()
311 .\"O function prints the error message associated
312 .\"O with the current value of \fIh_errno\fP on \fIstderr\fP.
313 (ÇÑ»ßͽÄê¤Î)
314 .BR herror ()
315 ´Ø¿ô¤Ï¸½ºß¤Î
316 .I h_errno
317 ¤ËÂбþ¤¹¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òɸ½à¥¨¥é¡¼ \fIstderr\fP ¤Ë½ÐÎϤ¹¤ë¡£
318 .PP
319 .\"O The (obsolete)
320 .\"O .BR hstrerror ()
321 .\"O function takes an error number
322 .\"O (typically \fIh_errno\fP) and returns the corresponding message string.
323 (ÇÑ»ßͽÄê¤Î)
324 .BR hstrerror ()
325 ´Ø¿ô¤Ï¥¨¥é¡¼ÈÖ¹æ (Ä̾ï¤Ï \fIh_errno\fP) ¤ò°ú¤­¿ô¤Ë¼è¤ê¡¢
326 Âбþ¤¹¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸Ê¸»úÎó¤òÊÖ¤¹¡£
327 .PP
328 .\"O The domain name queries carried out by
329 .\"O .BR gethostbyname ()
330 .\"O and
331 .\"O .BR gethostbyaddr ()
332 .\"O use a combination of any or all of the name server
333 .\"O .BR named (8),
334 .\"O a broken out line from \fI/etc/hosts\fP, and the Network
335 .\"O Information Service (NIS or YP), depending upon the contents of the
336 .\"O \fIorder\fP line in
337 .\"O .IR /etc/host.conf .
338 .\"O .\" (See
339 .\"O .\" .BR resolv+ (8)).
340 .\"O The default action is to query
341 .\"O .BR named (8),
342 .\"O followed by
343 .\"O .IR /etc/hosts .
344 .BR gethostbyname ()
345 ¤È
346 .BR gethostbyaddr ()
347 ¤Ë¤è¤Ã¤Æ¼Â¹Ô¤µ¤ì¤ë¥É¥á¥¤¥ó̾¤ÎÌ䤤¹ç¤ï¤»¤Ç¤Ï¡¢¥Í¡¼¥à¥µ¡¼¥Ð
348 .BR named (8)¡¢
349 .I /etc/hosts
350 ¤Î¥Ç¡¼¥¿¹Ô¡¢¤ª¤è¤Ó
351 Network Information Service (NIS ¤Þ¤¿¤Ï YP)
352 ¤¬ÁȤ߹ç¤ï¤»¤Æ»ÈÍѤµ¤ì¤ë¡£²¿¤¬»ÈÍѤµ¤ì¤ë¤«¤Ï¡¢
353 .I /etc/host.conf
354 ¤Î
355 .I order
356 ¹Ô¤ÎÆâÍƤˤè¤ê·è¤Þ¤ë¡£
357 .\" (¾Ü¤·¤¯¤Ï
358 .\" .BR resolv+ (8)
359 .\" ¤ò»²¾È)¡£
360 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¤Þ¤º
361 .BR named (8)
362 ¤ËÌ䤤¹ç¤ï¤»¤ò¹Ô¤¤¡¢¼¡¤¤¤Ç
363 .I /etc/hosts
364 ¤ò»²¾È¤¹¤ë¡£
365 .PP
366 .\"O The \fIhostent\fP structure is defined in \fI<netdb.h>\fP as follows:
367 .I hostent
368 ¹½Â¤ÂΤÏ
369 .I <netdb.h>
370 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
371 .sp
372 .in +4n
373 .nf
374 .ne 7
375 struct hostent {
376     char  *h_name;            /* official name of host */
377     char **h_aliases;         /* alias list */
378     int    h_addrtype;        /* host address type */
379     int    h_length;          /* length of address */
380     char **h_addr_list;       /* list of addresses */
381 }
382 .\"O #define h_addr h_addr_list[0] /* for backward compatibility */
383 #define h_addr h_addr_list[0] /* ²áµî¤È¤Î¸ß´¹À­¤Î¤¿¤á */
384 .fi
385 .in
386 .PP
387 .\"O The members of the \fIhostent\fP structure are:
388 .I hostent
389 ¹½Â¤ÂΤΥá¥ó¥Ð¤Ï°Ê²¼¤ÎÄ̤ꡣ
390 .TP
391 .I h_name
392 .\"O The official name of the host.
393 ¥Û¥¹¥È¤ÎÀµ¼°Ì¾ (official name)¡£
394 .TP
395 .I h_aliases
396 .\"O An array of alternative names for the host, terminated by a NULL pointer.
397 ¥Û¥¹¥È¤ÎÊÌ̾¤ÎÇÛÎó¡£ÇÛÎó¤Ï NULL ¥Ý¥¤¥ó¥¿¤Ç½ªÃ¼¤µ¤ì¤ë¡£
398 .TP
399 .I h_addrtype
400 .\"O The type of address; always
401 .\"O .B AF_INET
402 .\"O or
403 .\"O .B AF_INET6
404 .\"O at present.
405 ¥¢¥É¥ì¥¹¤Î¥¿¥¤¥×¡£¸½ºß¤Ï¤¹¤Ù¤Æ
406 .B AF_INET
407 ¤Þ¤¿¤Ï
408 .B AF_INET6
409 ¤Ç¤¢¤ë¡£
410 .TP
411 .I h_length
412 .\"O The length of the address in bytes.
413 ¥Ð¥¤¥Èñ°Ì¤Çɽ¤·¤¿¥¢¥É¥ì¥¹¤ÎŤµ¡£
414 .TP
415 .I h_addr_list
416 .\"O An array of pointers to network addresses for the host (in network byte
417 .\"O order), terminated by a NULL pointer.
418 ¥Û¥¹¥È¤Î¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤Ø¤Î¥Ý¥¤¥ó¥¿¤ÎÇÛÎó¡£
419 ÇÛÎó¤Ï NULL ¥Ý¥¤¥ó¥¿¤Ç½ªÃ¼¤µ¤ì¤ë¡£
420 ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤Ï¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À·Á¼°¤Ç¤¢¤ë¡£
421 .TP
422 .I h_addr
423 .\"O The first address in \fIh_addr_list\fP for backward compatibility.
424 .I h_addr_list
425 ¤ÎºÇ½é¤Î¥¢¥É¥ì¥¹¡£²áµî¤È¤Î¸ß´¹À­¤òÊݤĤ¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£
426 .\"O .SH "RETURN VALUE"
427 .SH ÊÖ¤êÃÍ
428 .\"O The
429 .\"O .BR gethostbyname ()
430 .\"O and
431 .\"O .BR gethostbyaddr ()
432 .\"O functions return the
433 .\"O .I hostent
434 .\"O structure or a NULL pointer if an error occurs.
435 .\"O On error, the
436 .\"O .I h_errno
437 .\"O variable holds an error number.
438 .BR gethostbyname ()
439 ¤ª¤è¤Ó
440 .BR gethostbyaddr ()
441 ´Ø¿ô¤Ï
442 .I hostent
443 ¹½Â¤ÂΤòÊÖ¤¹¡£¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¤é NULL ¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¥¨¥é¡¼¤ÎºÝ¤Ë¤Ï
444 .I h_errno
445 ÊÑ¿ô¤¬¥¨¥é¡¼¤ÎÈÖ¹æ¤òÊÝ»ý¤¹¤ë¡£
446 .\"O When non-NULL, the return value may point at static data, see the notes below.
447 ÊÖ¤êÃͤ¬ NULL ¤Ç¤Ê¤¤¾ì¹ç¡¢ÀÅŪ¥Ç¡¼¥¿¤ò¥Ý¥¤¥ó¥¿¤Ç»Ø¤·¤Æ¤¤¤ë¤³¤È¤â¤¢¤ë¡£
448 °Ê²¼¤Î¡ÖÃí°Õ¡×¤ò»²¾È¤¹¤ë¤³¤È¡£
449 .\"O .SH "ERRORS"
450 .SH ¥¨¥é¡¼
451 .\"O The variable \fIh_errno\fP can have the following values:
452 .I h_errno
453 ÊÑ¿ô¤Ï°Ê²¼¤ÎÃͤò¼è¤ê¤¦¤ë¡£
454 .TP
455 .B HOST_NOT_FOUND
456 .\"O The specified host is unknown.
457 »ØÄꤷ¤¿¥Û¥¹¥È¤¬¸«¤Ä¤«¤é¤Ê¤¤¡£
458 .TP
459 .\"O .B NO_ADDRESS " or " NO_DATA
460 .B NO_ADDRESS " ¤Þ¤¿¤Ï " NO_DATA
461 .\"O The requested name is valid but does not have an IP address.
462 »ØÄꤷ¤¿Ì¾Á°¤ÏÍ­¸ú¤À¤¬ IP ¥¢¥É¥ì¥¹¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
463 .TP
464 .B NO_RECOVERY
465 .\"O A nonrecoverable name server error occurred.
466 ¥Í¡¼¥à¥µ¡¼¥Ð¤ÎÉüµìÉÔǽ¤Ê¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
467 .TP
468 .B TRY_AGAIN
469 .\"O A temporary error occurred on an authoritative name server.
470 .\"O Try again later.
471 authoritative ¤Ê¥Í¡¼¥à¥µ¡¼¥Ð¤Ç°ì»þŪ¤Ê¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
472 »þ´Ö¤ò¤ª¤¤¤Æ¤â¤¦°ìÅٻ¤³¤È¡£
473 .\"O .SH FILES
474 .SH ¥Õ¥¡¥¤¥ë
475 .TP
476 .I /etc/host.conf
477 .\"O resolver configuration file
478 ̾Á°²ò·è¤ÎÀßÄê¥Õ¥¡¥¤¥ë
479 .TP
480 .I /etc/hosts
481 .\"O host database file
482 ¥Û¥¹¥È¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë
483 .TP
484 .I /etc/nsswitch.conf
485 .\"O name service switch configuration
486 ¥Í¡¼¥à¥µ¡¼¥Ó¥¹ÀÚÂØÀßÄê
487 .\"O .SH "CONFORMING TO"
488 .SH ½àµò
489 .\"O POSIX.1-2001 specifies
490 .\"O .BR gethostbyname (),
491 .\"O .BR gethostbyaddr (),
492 .\"O .BR sethostent (),
493 .\"O .BR endhostent (),
494 .\"O .BR gethostent (),
495 .\"O and
496 .\"O .IR h_errno ;
497 .\"O .BR gethostbyname (),
498 .\"O .BR gethostbyaddr (),
499 .\"O and
500 .\"O .IR h_errno
501 .\"O are marked obsolescent in that standard.
502 POSIX.1-2001 ¤Ç¤Ï¡¢
503 .BR gethostbyname (),
504 .BR gethostbyaddr (),
505 .BR sethostent (),
506 .BR endhostent (),
507 .BR gethostent (),
508 .I h_errno
509 ¤¬µ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢
510 .BR gethostbyaddr ()
511 ¤È
512 .BR gethostbyname ()
513 ¤ÏÇÑ»ßͽÄê¤Ç¤¢¤ë¤È¤µ¤ì¤Æ¤¤¤ë¡£
514 .\"O POSIX.1-2008 removes the specifications of
515 .\"O .BR gethostbyname (),
516 .\"O .BR gethostbyaddr (),
517 .\"O and
518 .\"O .IR h_errno ,
519 .\"O recommending the use of
520 .\"O .BR getaddrinfo (3)
521 .\"O and
522 .\"O .BR getnameinfo (3)
523 .\"O instead.
524 POSIX.1-2008 ¤Ç¤Ï
525 .BR gethostbyname (),
526 .BR gethostbyaddr (),
527 .I h_errno
528 ¤Î»ÅÍͤ¬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
529 Âå¤ï¤ê¤Ë¡¢
530 .BR getaddrinfo (3)
531 ¤È
532 .BR getnameinfo (3)
533 ¤Î»ÈÍѤ¬¿ä¾©¤µ¤ì¤Æ¤¤¤ë¡£
534 .\"O .SH NOTES
535 .SH Ãí°Õ
536 .\"O The functions
537 .\"O .BR gethostbyname ()
538 .\"O and
539 .\"O .BR gethostbyaddr ()
540 .\"O may return pointers to static data, which may be overwritten by
541 .\"O later calls.
542 .\"O Copying the
543 .\"O .I struct hostent
544 .\"O does not suffice, since it contains pointers; a deep copy is required.
545 .BR gethostbyname ()
546 ¤ª¤è¤Ó
547 .BR gethostbyaddr ()
548 ´Ø¿ô¤ÏÀÅŪ¥Ç¡¼¥¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
549 ¤³¤Î¥Ý¥¤¥ó¥¿¤Ï¡¢¤½¤Î¸å¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤­¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
550 .I hostent
551 ¹½Â¤ÂΤϥݥ¤¥ó¥¿¤ò´Þ¤ó¤Ç¤¤¤ë¤Î¤Ç¡¢¹½Â¤ÂΤΥ³¥Ô¡¼¤À¤±¤Ç¤ÏÉÔ½½Ê¬¤Ç¤¢¤ë;
552 ¤è¤ê¿¼¤¤¥³¥Ô¡¼¤¬É¬ÍפǤ¢¤ë¡£
553 .LP
554 .\"O In the original BSD implementation the
555 .\"O .I len
556 .\"O argument
557 .\"O of
558 .\"O .BR gethostbyname ()
559 .\"O was an
560 .\"O .IR int .
561 ¥ª¥ê¥¸¥Ê¥ë¤Î BSD ¤Î¼ÂÁõ¤Ç¤Ï¡¢
562 .BR gethostbyname ()
563 ¤Î
564 .I len
565 °ú¤­¿ô¤Ï
566 .I int
567 ¤Ç¤¢¤Ã¤¿¡£
568 .\"O The SUSv2 standard is buggy and declares the
569 .\"O .I len
570 .\"O argument of
571 .\"O .BR gethostbyaddr ()
572 .\"O to be of type
573 .\"O .IR size_t .
574 .\"O (That is wrong, because it has to be
575 .\"O .IR int ,
576 .\"O and
577 .\"O .I size_t
578 .\"O is not.
579 .\"O POSIX.1-2001 makes it
580 .\"O .IR socklen_t ,
581 .\"O which is OK.)
582 .\"O See also
583 .\"O .BR accept (2).
584 SUSv2 É¸½à¤Ï¥Ð¥°¤¬Â¿¤¯¡¢
585 .BR gethostbyaddr ()
586 ¤Î
587 .I len
588 ¥Ñ¥é¥á¡¼¥¿¤ò
589 .I size_t
590 ·¿¤È¤·¤ÆÀë¸À¤·¤Æ¤¤¤ë¡£
591 (¤³¤ì¤Ï¸í¤ê¤Ç¡¢
592 .I size_t
593 ·¿¤Ç¤Ï¤Ê¤¯
594 .I int
595 ·¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
596 POSIX.1-2001 ¤Ç¤Ï¤³¤ì¤ò
597 .I socklen_t
598 ¤È¤·¤Æ¤¤¤ë¤¬¡¢¤³¤ì¤Ï OK¡£)
599 .BR accept (2)
600 ¤â»²¾È¡£
601 .LP
602 .\"O The BSD prototype for
603 .\"O .BR gethostbyaddr ()
604 .\"O uses
605 .\"O .I const char *
606 .\"O for the first argument.
607 .BR gethostbyaddr ()
608 ¤Î BSD ¤Î¥×¥í¥È¥¿¥¤¥×¤Ï¡¢ºÇ½é¤Î°ú¤­¿ô¤È¤·¤Æ
609 .I const char *
610 ¤ò»È¤¦¡£
611 .\"O .SS "System V/POSIX Extension"
612 .SS "System V/POSIX ³ÈÄ¥"
613 .\"O POSIX requires the
614 .\"O .BR gethostent ()
615 .\"O call, that should return the next entry in the host data base.
616 POSIX ¤Ç¤Ï¡¢
617 .BR gethostent ()
618 ¤¬É¬¿Ü¤È¤µ¤ì¤Æ¤¤¤ë¡£
619 ¤³¤Î´Ø¿ô¤Ï¥Û¥¹¥È¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¼¡¤Î¥¨¥ó¥È¥ê¤òÊÖ¤¹¡£
620 .\"O When using DNS/BIND this does not make much sense, but it may
621 .\"O be reasonable if the host data base is a file that can be read
622 .\"O line by line.
623 .\"O On many systems a routine of this name reads
624 .\"O from the file
625 .\"O .IR /etc/hosts .
626 DNS/BIND ¤ò»È¤¦¾ì¹ç¤Ï¤¢¤Þ¤ê°ÕÌ£¤ò»ý¤¿¤Ê¤¤¤¬¡¢
627 ¥Û¥¹¥È¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ 1 ¹Ô¤º¤ÄÆɤ߹þ¤Þ¤ì¤ë¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¾ì¹ç¤Ï°ÕÌ£¤¬¤¢¤ë¡£
628 ¿¤¯¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢¤³¤Î̾Á°¤Î¥ë¡¼¥Á¥ó¤Ï¥Õ¥¡¥¤¥ë
629 .I /etc/hosts
630 ¤òÆɤ߹þ¤à¡£
631 .\"O .\" e.g., Linux, FreeBSD, UnixWare, HP-UX
632 .\"O It may be available only when the library was built without DNS support.
633 .\"O .\" e.g., FreeBSD, AIX
634 .\"O The glibc version will ignore ipv6 entries.
635 .\"O This function is not reentrant,
636 .\"O and glibc adds a reentrant version
637 .\"O .BR gethostent_r ().
638 .\" Î㤨¤Ð¡¢Linux, FreeBSD, UnixWare, HP-UX
639 DNS ¥µ¥Ý¡¼¥È¤Ê¤·¤Ç¥é¥¤¥Ö¥é¥ê¤¬¥Ó¥ë¥É¤µ¤ì¤¿¾ì¹ç¤Ë¤Î¤ßÍøÍѲÄǽ¤Ç¤¢¤ë¡£
640 .\" Î㤨¤Ð¡¢FreeBSD, AIX
641 glibc ÈǤϠipv6 ¥¨¥ó¥È¥ê¤ò̵»ë¤¹¤ë¡£
642 ¤³¤Î´Ø¿ô¤Ï¥ê¥¨¥ó¥È¥é¥ó¥È (reentrant) ¤Ç¤Ï¤Ê¤¯¡¢
643 glibc ¤Ë¤Ï¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤÎ
644 .BR gethostent_r ()
645 ¤¬Äɲ䵤줿¡£
646 .\"O .SS "GNU Extensions"
647 .SS "GNU ³ÈÄ¥"
648 .\"O Glibc2 also has a
649 .\"O .BR gethostbyname2 ()
650 .\"O that works like
651 .\"O .BR gethostbyname (),
652 .\"O but permits to specify the address family to which the address must belong.
653 glibc2 ¤Ë¤Ï
654 .BR gethostbyname2 ()
655 ¤â¤¢¤ê¡¢
656 .BR gethostbyname ()
657 ¤ÈƱ¤¸¤è¤¦¤ËÆ°ºî¤¹¤ë¤¬¡¢
658 ¤³¤Á¤é¤Ï¥¢¥É¥ì¥¹¤¬Â°¤¹¤ë¥¢¥É¥ì¥¹¥Õ¥¡¥ß¥ê¡¼¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
659 .LP
660 .\"O Glibc2 also has reentrant versions
661 .\"O .BR gethostent_r (),
662 .\"O .BR gethostbyaddr_r (),
663 .\"O .BR gethostbyname_r ()
664 .\"O and
665 .\"O .BR gethostbyname2_r ().
666 glibc2 ¤Ë¤Ï¥ê¥¨¥ó¥È¥é¥ó¥È¤Ê
667 .BR gethostent_r (),
668 .BR gethostbyaddr_r (),
669 .BR gethostbyname_r ()
670 ¤È
671 .BR gethostbyname2_r ()
672 ¤â¤¢¤ë¡£
673 .\"O The caller supplies a
674 .\"O .I hostent
675 .\"O structure
676 .\"O .I ret
677 .\"O which will be filled in on success, and a temporary work buffer
678 .\"O .I buf
679 .\"O of size
680 .\"O .IR buflen .
681 ¸Æ¤Ó½Ð¤·Â¦¤Ï¡¢À®¸ù»þ¤Ë·ë²Ì¤¬³ÊǼ¤µ¤ì¤ë
682 .I hostent
683 ¹½Â¤ÂÎ
684 .I ret
685 ¤È¡¢Â礭¤µ
686 .I buflen
687 ¤Î°ì»þŪ¤Êºî¶È¥Ð¥Ã¥Õ¥¡
688 .I buf
689 ¤òÄ󶡤¹¤ë¡£
690 .\"O After the call,
691 .\"O .I result
692 .\"O will point to the result on success.
693 .\"O In case of an error
694 .\"O or if no entry is found
695 .\"O .I result
696 .\"O will be NULL.
697 ¥³¡¼¥ë½ªÎ»¸å¡¢À®¸ù¤·¤¿¾ì¹ç
698 .I result
699 ¤Ï·ë²Ì¤ò»Ø¤·¤Æ¤¤¤ë¡£
700 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤Þ¤¿¤Ï¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
701 .I result
702 ¤Ï NULL ¤Ë¤Ê¤ë¡£
703 .\"O The functions return 0 on success and a nonzero error number on failure.
704 .\"O In addition to the errors returned by the nonreentrant
705 .\"O versions of these functions, if
706 .\"O .I buf
707 .\"O is too small, the functions will return
708 .\"O .BR ERANGE ,
709 .\"O and the call should be retried with a larger buffer.
710 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢À®¸ù¤·¤¿¾ì¹ç 0 ¤òÊÖ¤·¡¢¼ºÇԤξì¹ç¤Ï 0 °Ê³°¤Î¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤¹¡£
711 ¤³¤ì¤é¤Î´Ø¿ô¤Î¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ê¤¤¥Ð¡¼¥¸¥ç¥ó¤¬ÊÖ¤¹¥¨¥é¡¼¤Ë²Ã¤¨¤Æ¡¢
712 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢
713 .I buf
714 ¤¬¾®¤µ¤¹¤®¤¿¾ì¹ç¤Ë
715 .B ERANGE
716 ¤òÊÖ¤¹¡£¤³¤Î¾ì¹ç¤Ï¤â¤Ã¤ÈÂ礭¤Ê¥Ð¥Ã¥Õ¥¡¤òÍÑ°Õ¤·¤Æ
717 ´Ø¿ô¸Æ¤Ó½Ð¤·¤òºÆÅÙ¹Ô¤¦¤Ù¤­¤Ç¤¢¤ë¡£
718 .\"O The global variable
719 .\"O .I h_errno
720 .\"O is not modified, but the address of a variable in which to store error numbers
721 .\"O is passed in
722 .\"O .IR h_errnop .
723 Âç°èÊÑ¿ô
724 .I h_errno
725 ¤ÏÊѹ¹¤µ¤ì¤Ê¤¤¤¬¡¢¥¨¥é¡¼ÈÖ¹æ¤ò³ÊǼ¤¹¤ëÊÑ¿ô¤Î¥¢¥É¥ì¥¹¤¬
726 .I h_errnop
727 ¤ËÅϤµ¤ì¤ë¡£
728 .\"O .SH BUGS
729 .SH ¥Ð¥°
730 .\"O .BR gethostbyname ()
731 .\"O does not recognize components of a dotted IPv4 address string
732 .\"O that are expressed in hexadecimal.
733 .BR gethostbyname ()
734 ¤Ï¡¢16¿Ê¿ôɽ¸½¤Î¥É¥Ã¥È¶èÀÚ¤ê¤Î IPv4 ¥¢¥É¥ì¥¹Ê¸»úÎó¤ÎÍ×ÁǤòǧ¼±¤·¤Ê¤¤¡£
735 .\" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482973
736 .\"O .SH "SEE ALSO"
737 .SH ´ØÏ¢¹àÌÜ
738 .BR getaddrinfo (3),
739 .\" .BR getipnodebyaddr (3),
740 .\" .BR getipnodebyname (3),
741 .BR getnameinfo (3),
742 .BR inet (3),
743 .BR inet_ntop (3),
744 .BR inet_pton (3),
745 .BR resolver (3),
746 .BR hosts (5),
747 .BR nsswitch.conf (5),
748 .BR hostname (7),
749 .BR named (8)
750 .\" .BR resolv+ (8)