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
|
.\" 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 Sat May 22 18:43:54 1993, David Metcalfe
.\" Modified Sun Jul 25 10:42:30 1993, Rik Faith (faith@cs.unc.edu)
.\" Modified Sun Feb 16 13:23:10 1997, Andries Brouwer (aeb@cwi.nl)
.\" Modified Mon Dec 21 14:49:33 1998, Andries Brouwer (aeb@cwi.nl)
.\" Modified Sat Aug 12 18:11:32 2000, Andries Brouwer (aeb@cwi.nl)
.\" Modified Sat May 19 23:37:50 2001, Andries Brouwer (aeb@cwi.nl)
.\"
.\" 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
.\"
.TH GETHOSTBYNAME 3 2000-08-12 "BSD" "Linux Programmer's Manual"
.SH ̾
gethostbyname, gethostbyaddr, sethostent, endhostent, herror, hstrerror \- ͥåȥΥۥȤΥȥ
.SH
.nf
.B #include <netdb.h>
.B extern int h_errno;
.sp
.BI "struct hostent *gethostbyname(const char *" name );
.sp
.B #include <sys/socket.h> " " /* for AF_INET */
.BI "struct hostent *gethostbyaddr(const char *" addr ,
.BI " 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
/* GNU extensions */
.br
.BI "struct hostent *gethostbyname2(const char *" name ", int " af );
.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
.B 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
ΤߤǤ롣
.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)
)
ǥեȤǤϤޤ
.B 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
Ǥ롣
.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
ѿ顼ֹݻ롣
.SH 顼
.I h_errno
ѿϰʲͤꤦ롣
.TP
.B HOST_NOT_FOUND
ꤷۥȤĤʤ
.TP
.B NO_ADDRESS " ޤ " NO_DATA
ꤷ̾ͭ IP ɥ쥹äƤʤ
.TP
.B NO_RECOVERY
͡ॵСǽʥ顼ä
.TP
.B TRY_AGAIN
aurhoritative ʥ͡ॵСǰŪʥ顼ä֤
⤦ٻȡ
.SH ե
.TP
.I /etc/host.conf
̾ե
.TP
.I /etc/hosts
ۥȤΥǡ١ե
.SH
BSD 4.3.
.SH
SUS-v2 ϥХ¿
.B gethostbyaddr()
.I len
ѥ
.I size_t
ȤƤ롣
(ϸǡ
.I size_t
ǤϤʤ
.I int
ǤʤФʤʤ
POSIX 1003.1-2001 ǤϤ
.I socklen_t
ȤƤ뤬 OK)
.LP
.BR gethostbyname ()
.BR gethostbyaddr ()
ؿŪǡؤΥݥ֤
ΥݥϡθθƤӽФǾ뤫⤷ʤ
.I hostent
¤ΤϥݥޤǤΤǡ¤ΤΥԡǤԽʬǤ롣
- 꿼ԡɬפǤ롣
.LP
glibc2 ˤ
.B gethostbyname2()
⤢ꡢ
.B gethostbyname()
Ʊ褦ư뤬
ϥɥ쥹°륢ɥ쥹եߥꤹ뤳ȤǤ롣
.LP
glibc2 ˤϥꥨȥ (reentrant)
.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
Ϥ롣
.PP
POSIX 1003.1-2001
.B gethostbyaddr()
.B gethostbyname()
ΤΤȤ
.sp
.nf
.BI "struct hostent *getipnodebyaddr (const void *restrict " addr ,
.BI " socklen_t " len ", int " type ", int *restrict " error_num );
.sp
.BI "struct hostent *getipnodebyname (const char *" name ,
.BI " int " type ", int " flags ", int *" error_num );
.sp
ƳƤ롣
.SH Ϣ
.BR resolver (3),
.BR hosts (5),
.BR hostname (7),
.BR resolv+ (8),
.BR named (8)
|