OSDN Git Service

9075b180f2fb5e6d244b3efd7ad6a3fb8351f89c
[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)