File: gethostbyname.3

package info (click to toggle)
manpages-ja 0.5.0.0.20050315-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,620 kB
  • ctags: 4
  • sloc: sh: 12,675; perl: 157; makefile: 106
file content (375 lines) | stat: -rw-r--r-- 9,869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified 1993-05-22, David Metcalfe
.\" Modified 1993-07-25, Rik Faith (faith@cs.unc.edu)
.\" Modified 1997-02-16, Andries Brouwer (aeb@cwi.nl)
.\" Modified 1998-12-21, Andries Brouwer (aeb@cwi.nl)
.\" Modified 2000-08-12, Andries Brouwer (aeb@cwi.nl)
.\" Modified 2001-05-19, Andries Brouwer (aeb@cwi.nl)
.\" Modified 2002-08-05, Michael Kerrisk
.\" Modified 2004-10-31, Andries Brouwer
.\"
.\" Japanese Version Copyright (c) 1998-2000 NAKANO Takeo all rights reserved.
.\" Translated Thu Apr 30 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Modified Sun Dec 6 by NAKANO Takeo
.\" Updated & Modified Thu Oct 12 1999 by NAKANO Takeo
.\" Updated & Modified Sun Jul  1 11:51:26 JST 2001
.\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated & Modified Thu Jan  3 15:22:14 JST 2002 by Yuichi SATO
.\" Updated & Modified Thu Nov 27 01:28:24 JST 2003
.\"         by Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified Mon Jan 10 12:55:35 JST 2005 by Yuichi SATO
.\"
.TH GETHOSTBYNAME 3 2004-10-31 "" "Linux Programmer's Manual"
.SH ̾
gethostbyname, gethostbyaddr, sethostent, gethostend, endhostent, herror, hstrerror \- ͥåȥΥۥȤΥȥ 
.SH 
.nf
.B #include <netdb.h>
.B extern int h_errno;
.sp
.BI "struct hostent *gethostbyname(const char *" name );
.sp
.BR "#include <sys/socket.h>" "       /* AF_INET Ȥ */"
.BI "struct hostent *"
.br
.BI "gethostbyaddr(const void *" addr ", int " len ", int " type );
.sp
.BI "void sethostent(int " stayopen );
.sp
.B void endhostent(void);
.sp
.BI "void herror(const char *" s );
.sp
.BI "const char *hstrerror(int " err );
.sp 2
/* SYSV/POSIX ĥ */
.br
.B struct hostent *gethostent(void);
.sp 2
/* GNU ĥ */
.br
.BI "struct hostent *gethostbyname2(const char *" name ", int " af );
.sp
.BI "int gethostent_r("
.BI "  struct hostent *" ret ", char *" buf ", size_t " buflen ,
.BI "  struct hostent **" result ", int *" h_errnop );
.sp
.BI "int gethostbyname_r(const char *" name ,
.BI "  struct hostent *" ret ", char *" buf ", size_t " buflen ,
.BI "  struct hostent **" result ", int *" h_errnop );
.sp
.BI "int gethostbyname2_r(const char *" name ", int " af,
.BI "  struct hostent *" ret ", char *" buf ", size_t " buflen ,
.BI "  struct hostent **" result ", int *" h_errnop );
.fi
.SH 
.BR gethostbyname ()
ؿͿ줿ۥ̾
.I name
б빽¤
.I hostent
֤
.I name
ϥۥ̾ɥåȶڤ IPv4 ɥ쥹ڤ
(ɥåȶڤǤפ⤷ʤ) IPv6 ɥ쥹Τ줫Ǥ롣
(IPv6 ɥ쥹εҤˤĤƤ RFC 1884 򻲹ͤˤƤۤ)
.I name
 IPv4  IPv6 Υɥ쥹äˤϡ
̾ (lookup) ϹԤʤ
.BR gethostbyname ()
ñ
.I name
򤽤Τޤ
.I hostent
¤Τ
.I h_name
եɤ˥ԡ

.I name

.I struct in_addr
ɽǡƱ¤Τ
.I h_addr_list[0]
եɤơι¤Τ֤
.I name
ɥåȤǽλƤơĴĶѿ
.B HOSTALIASES
ꤵƤϡޤ
.B HOSTALIASES
ǻꤵƤ륨ꥢե뤫
.I name
Υȥ꤬ (եΥեޥåȤˤĤƤ
.BR hostname (7)
򻲾ȤΤ)
.I name
ɥåȤǽλƤʤиߤΥɥᥤȤοƥɥᥤ󤬸롣
.PP
.B gethostbyaddr()
ؿͿ줿ۥȥɥ쥹
.I addr
(Ĺ \fIlen\fP  \fItype\fP) б빽¤
.I hostent
֤
Ѥ뤳ȤΤǤ륿פ
.B AF_INET

.B AF_INET6
Ǥ롣
ۥȥɥ쥹ϥɥ쥹פ˰¸
¤ΤؤΥݥ󥿤Ǥ롣
㤨Сɥ쥹 AF_INET ФƤ
(\fIinet_addr()\fP θƤӽФ)
\fBstruct in_addr *\fP Ǥ롣
.PP
.B sethostent()
ؿϡ͡ॵСؤ³ͼꤹ롣
.I stayopen
 (1) ʤС͡ॵСؤ䤤碌ˤϡ
³줿 TCP åȤѤϢ³䤤碌δ֤³ݻ롣
ʤХ͡ॵСؤ䤤碌 UDP ǡѤ롣
.PP
.B endhostent()
ؿϥ͡ॵСؤ䤤碌Ѥ TCP ³Ѥλ롣
.PP
.B herror()
ؿ (⤦Ť) ϸߤ
.I h_errno
б륨顼å stderr ˽Ϥ롣
.PP
.B hsterror()
ؿ (⤦Ť) ϥ顼ֹ (ŵŪˤ \fIh_errno\fP) 
˼ꡢб륨顼åʸ֤
.PP
.BR gethostbyname ()

.BR gethostbyaddr ()
ˤäƼ¹Ԥɥᥤ̾䤤碌Ǥϡ͡ॵС
.BR named (8)
.I /etc/hosts
Υǡԡ
Network Information Service (NIS ޤ YP)
Τ줫뤤Ϥ٤ƤѤ롣
.I /etc/host.conf

.I order
ԤƤ˰¸ (ܤ
.BR resolv+ (8)
򸫤)
ǥեȤǤϤޤ
.BR named (8)
䤤碌
.I /etc/hosts
.PP
.I hostent
¤Τ
.I <netdb.h>
ǰʲΤ褦Ƥ:
.sp
.RS
.nf
.ne 7
.ta 8n 16n 32n
struct hostent {
	char	*h_name;		/* official name of host */
	char	**h_aliases;		/* alias list */
	int	h_addrtype;		/* host address type */
	int	h_length;		/* length of address */
	char	**h_addr_list;		/* list of addresses */
}
#define h_addr	h_addr_list[0]		/* for backward compatibility */
.ta
.fi
.RE
.PP
.I hostent
¤ΤΥФϰʲ̤ꡣ
.TP
.I h_name
ۥȤ̾ (official name)
.TP
.I h_aliases
ۥȤ̾ʤ 0 ǽü롣
.TP
.I h_addrtype
ɥ쥹ΥסߤϤ٤
.B AF_INET
ޤ
.B AF_INET6
Ǥ롣
.TP
.I h_length
Хñ̤ɽɥ쥹Ĺ
.TP
.I h_addr_list
ۥȤΥͥåȥɥ쥹ͥåȥХȥɽ 
0 ǽü롣
.TP
.I h_addr
.I h_addr_list
κǽΥɥ쥹ȤθߴݤĤΤΤǤ롣
.SH ֤
.B gethostbyname()

.B gethostbyaddr()
ؿ
.I hostent
¤Τ֤顼ä NULL ݥ󥿤֤顼κݤˤ
.I h_errno
ѿ顼ֹݻ롣
֤ͤ NULL Ǥʤ硢Ūǡݥ󥿤ǻؤƤ뤳Ȥ⤢롣
ʲΡաפ򻲾Ȥ뤳ȡ
.SH 顼
.I h_errno
ѿϰʲͤꤦ롣
.TP
.B HOST_NOT_FOUND
ꤷۥȤĤʤ
.TP
.B NO_ADDRESS " ޤ " NO_DATA
ꤷ̾ͭ IP ɥ쥹äƤʤ
.TP
.B NO_RECOVERY
͡ॵСǽʥ顼ä
.TP
.B TRY_AGAIN
authoritative ʥ͡ॵСǰŪʥ顼ä֤򤪤
⤦ٻȡ
.SH ե
.TP
.I /etc/host.conf
̾ե
.TP
.I /etc/hosts
ۥȤΥǡ١ե
.SH 
BSD 4.3.
.SH "SYSV/POSIX ĥ"
POSIX Ǥϡۥȥǡ١μΥȥ֤
.BR gethostent ()
ɬפȤ롣
DNS/BIND ȤϤޤ̣ʤ
ۥȥǡ١ 1 Ԥɤ߹ޤեǤϰ̣롣
¿ΥƥǤϡ̾Υ롼ϥե
.I /etc/hosts
ɤ߹ࡣ
.\" 㤨СLinux, FreeBSD, Unixware, HP-UX
DNS ݡȤʤǥ饤֥꤬ӥɤ줿ˤΤѲǽǤ롣
.\" 㤨СFreeBSD, AIX
glibc Ǥ ipv6 ȥ̵뤹롣
δؿϥꥨȥ (reentrant) ǤϤʤ
glibc ˤϥꥨȥǤ
.BR gethostent_r ()
ɲä줿
.SH "GNU ĥ"
glibc2 ˤ
.B gethostbyname2()
⤢ꡢ
.B gethostbyname()
Ʊ褦ư뤬
ϥɥ쥹°륢ɥ쥹եߥ꡼ꤹ뤳ȤǤ롣
.LP
glibc2 ˤϥꥨȥȤ
.B gethostbyname_r()

.B gethostbyname2_r()
⤢롣
δؿϡ 0 ֤Ԥ 0 ʳ֤
ߤΤȤθƤӽФη̤ϥɥ쥹
.I ret
ι¤Τ˳Ǽ롣
ƤӽФθ塢Ԥ
.RI * result
 NULL ˤʤꡢ
.RI * result
̤ؤ
­ǡĹ
.I buflen
ΥХåե
.I buf
˳Ǽ롣
(Хåե硢δؿ
.B ERANGE
֤)
ѿ
.I h_errno
ѹʤ顼ֹǼѿΥɥ쥹
.I h_errnop 
Ϥ롣
.SH 
.BR gethostbyname ()

.BR gethostbyaddr ()
ؿŪǡؤΥݥ󥿤֤
Υݥ󥿤ϡθθƤӽФǾ񤭤뤫⤷ʤ
.I hostent
¤Τϥݥ󥿤ޤǤΤǡ¤ΤΥԡǤԽʬǤ롣
- 꿼ԡɬפǤ롣
.LP
SUS-v2 ϥХ¿
.B gethostbyaddr()

.I len
ѥ᡼
.I size_t
ȤƤ롣
(ϸǡ
.I size_t
ǤϤʤ
.I int
ǤʤФʤʤ
POSIX 1003.1-2001 ǤϤ
.I socklen_t
ȤƤ뤬 OK)
.LP
.B gethostbyaddr()
 BSD ΥץȥפϡǽΰȤ
.I const char *
Ȥ
.LP
POSIX 1003.1-2001 
.B gethostbyaddr()

.B gethostbyname()
Ѥ줫äΤȤƤ롣
.BR getaddrinfo (3),
.BR getnameinfo (3),
.BR gai_strerror (3)
򻲾Ȥ뤳ȡ
.SH Ϣ
.BR getaddrinfo (3),
.BR getipnodebyaddr (3),
.BR getipnodebyname (3),
.BR getnameinfo (3),
.BR inet_ntop (3),
.BR inet_pton (3),
.BR resolver (3),
.BR hosts (5),
.BR hostname (7),
.BR named (8),
.BR resolv+ (8)