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
|
.\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
.\"
.\" 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: RFC 2553
.\"
.\" 2005-08-09, mtk, added AI_ALL, AI_ADDRCONFIG, AI_V4MAPPED,
.\" and AI_NUMERICSERV.
.\"
.\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
.\" Translated Sun Jan 14 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Updated Oct 9 2005 by Kentaro Shirakata <argrath@ub32.org>
.\"
.\"WORD: null pointer ̥롦ݥ
.\"
.TH getaddrinfo 3 2000-12-18 "Linux Man Page" "Linux Programmer's Manual"
.SH ̾
getaddrinfo, freeaddrinfo, gai_strerror \- ͥåȥΥɥ쥹ȥӥѴ
.SH
.nf
.B #include <sys/types.h>
.B #include <sys/socket.h>
.B #include <netdb.h>
.sp
.BI "int getaddrinfo(const char *" "node" ", const char *" "service" ,
.BI " const struct addrinfo *" "hints" ,
.BI " struct addrinfo **" "res" );
.sp
.BI "void freeaddrinfo(struct addrinfo *" "res" );
.sp
.BI "const char *gai_strerror(int " "errcode" );
.fi
.SH
.BR getaddrinfo (3)
ؿϡ4 Ĥδؿ
.BR getipnodebyname (3),
.BR getipnodebyaddr (3),
.BR getservbyname (3),
.BR getservbyport (3)
εǽޤȤưĤΥեˤΤǤ롣
.BR getaddrinfo (3)
ؿϥåɥդǡ
ҤȤİʾΥåȥɥ쥹¤Τ롣
ι¤Τ
.BR bind (2)
.BR connect (2)
ʤɤδؿǥ饤ѡСѤΥåȤݤ
Ѥ뤳ȤǤ롣
.PP
.BR getaddrinfo (3)
ؿ뤳ȤΤǤΤ IPv4 ɥ쥹¤ΤǤϤʤ
IPv6 ΥݡȤƤ륷ƥʤ
IPv6 Υåȥɥ쥹¤ΤǤ롣
Υåȥɥ쥹¤Τϡ
饤Ȥ䥵СǥåȤݤˡ
.BR bind (2)
.BR connect (2)
ľѤǤ롣
.PP
δؿѤ
.I addrinfo
¤ΤˤϰʲΥСޤޤƤ롣
.sp
.nf
.B struct addrinfo {
.BI " int " "ai_flags" ";"
.BI " int " "ai_family" ";"
.BI " int " "ai_socktype" ";"
.BI " int " "ai_protocol" ";"
.BI " size_t " "ai_addrlen" ";"
.BI " struct sockaddr *" "ai_addr" ";"
.BI " char *" "ai_canonname" ";"
.BI " struct addrinfo *" "ai_next" ";"
.B };
.fi
.PP
.BR getaddrinfo (3)
ϡ
ưŪ˳Ƥ
.I addrinfo
¤ΤΥꥹȤ
ΥꥹȤؤΥݥ
.I res
ꤹ롣
ƹ¤Τ
.I ai_next
Сǥ롣
ꥹȤ
.I addrinfo
¤ΤʣĤˤʤ뤳Ȥ⤢ꡢͳϤĤ롣
ͥåȥۥȤޥۡξ硢
ʣΥåȥץȥƱӥȤ
(ҤȤĤ
.B SOCK_STREM
ɥ쥹ǡ⤦ҤȤĤ
.B SOCK_DGRAM
ɥ쥹Ǥʤ) 硢롣
.PP
.IR ai_family ,
.IR ai_socktype ,
.I ai_protocol
Сϡ줾
.BR socket (2)
ƥॳбƱ̣ġ
.BR getaddrinfo (3)
ؿ IPv4 IPv6 Τɤ餫Υɥ쥹եߥΥåȥɥ쥹֤
.RI ( ai_family
.B AF_INET
ޤ
.B AF_INET6
Τɤ餫˥åȤ)
.PP
.I hints
ѥˤϡ˾ΥåȤΥפץȥ
ꤹ롣
.I hints
NULL
ˤ뤳Ȥϡɤʥͥåȥɥ쥹ץȥǤ褤Ȥ̣롣
Υѥ NULL ǤʤȤϡ
.I addrinfo
¤ΤؤΥݥȤʤ롣
ι¤Τ
.IR ai_familiy ,
.IR ai_socktype ,
.I ai_protocol
Сǡ˾Υåȥפʤɤꤹ롣
.I ai_family
.B AF_UNSPEC
ꤹȡǤդΥץȥեߥ̣ (㤨 IPv4 IPv6)
.I ai_socktype
.I ai_protocol
0 ꤹȡ
ƱͤǤդΥåȥפץȥդ뤳Ȥ̣롣
.I ai_flags
Сˤɲåץꤹ (ϲΤȤ)
ʣΥե饰ꤹˤϡ OR ȤäƻꤹФ褤
.I hints
ѥΤ¾ΥСˤϡ
0 (ޤϥ̥롦ݥ) ʤФʤʤ
.PP
.I node
ѥ
.I service
ѥΤɤ餫 NULL ˤƤ褤 (ξƱ NULL Բ)
.I node
ˤϿͷΥͥåȥɥ쥹
(IPv4 ʤɥåȶڤ 10 ʷ
IPv6 ʤ 16 ʷ) 뤤ϥͥåȥۥ̾ꤹ롣
Ԥξϡͥåȥɥ쥹졢̾褬Ԥʤ롣
.I hints.ai_flags
.B AI_NUMERICHOST
ե饰ޤޤƤϡ
.I node
ѥϿŪʥͥåȥɥ쥹ǤʤФʤʤ
.B AI_NUMERICHOST
ե饰Ȥȡ
֤γݤǽΤ뤹٤ƤΥͥåȥۥȥɥ쥹θ롣
.PP
.BR getaddrinfo (3)
ؿ
.I addrinfo
¤ΤΥꥹȤ뤬
줾Υͥåȥɥ쥹
.I hints
ѥDzݤ줿٤Ƥ¤˽äƤ롣
.I hints.ai_flags
.B AI_CANONNAME
ե饰ޤޤƤ硢
.I addrinfo
¤Τκǽ
.I ai_canonname
եɤˤϥۥȤθ̾ؤ褦ꤵ롣
.IR ai_family ,
.IR ai_socktype ,
.I ai_protocol
ƥСˤϥåΥѥꤵ롣
.I ai_addr
Сˤϥåȥɥ쥹ؤΥݥޤ졢
.I ai_addrlen
Сˤϥåȥɥ쥹Ĺ (Хñ) ޤ롣
.PP
.I node
NULL ξ硢ƥåȹ¤ΤΥͥåȥɥ쥹
.B AI_PASSIVE
ե饰˴Ťƽ
(Υե饰
.I hints.ai_flags
ꤵ)
.B AI_PASSIVE
ե饰åȤƤ硢
ƥåȹ¤ΤΥͥåȥɥ쥹ꤵʤޤޤȤʤ
(: IPv4 ξ INADDR_ANY ˡIPv6 ξ IN6ADDR_ANY_INIT )
Ϥ٤ƤΥͥåȥɥ쥹ǥ饤³Ԥ褦
СץꥱѤ롣
.B AI_PASSIVE
ե饰åȤƤʤ硢
ͥåȥɥ쥹 loopback եɥ쥹ꤵ롣
ƱͥåȥۥȾưƤ륵С³褦
饤ȥץꥱѤ롣
.PP
.I hints.ai_flags
.B AI_ADDRCONFIG
ޤ硢
.I result
ؤꥹȤˤϡ
륷ƥ˺Ĥ IPv4 ɥ쥹ꤵƤ
IPv4 ɥ쥹֤졢
륷ƥ˺Ĥ IPv6 ɥ쥹ꤵƤ
IPv6 ɥ쥹֤롣
.PP
.I hint.ai_flags
.B AI_V4MAPPED
ꤵƤơ
.I hints.ai_family
.B AF_INET6
ꤵ졢
ޥå IPv6 ɥ쥹Ĥʤä硢
.I result
ؤꥹȤˤ IPv4-mapped IPv6 ɥ쥹֤롣
.I hints.ai_family
.B AI_V4MAPPED
.B AI_ALL
ξꤵƤ硢
.I result
ؤꥹȤˤ IPV6 ɥ쥹 IPv4-mapped IPv6 ɥ쥹
ξ֤롣
.B AI_V4MAPPED
ꤵƤʤ硢
.B AI_ALL
̵뤵롣
.PP
.I service
ϡƥåȹ¤ΤΥͥåȥɥ쥹Υݡֹꤹ롣
.I service
NULL ξ硢ݡֹϽʤ
.I hints.ai_flags
.B AI_NUMERICSERV
ꤵ졢
.I service
NULL Ǥʤ硢
.I service
ϿͤΥݡֹޤʸؤʤФʤʤ
Υե饰ϡ̾襵ӥפǤ뤳ȤʬäƤˡ
ӥεư뤿Ѥ롣
.PP
.BR freeaddrinfo (3)
ؿϡ
ꥹ
.I res
ФưŪ˳Ƥ줿롣
.SH ֤
.BR getaddrinfo (3)
0 ֤ԤȰʲ 0 Υ顼ɤΤ줫֤
.TP
.B EAI_ADDRFAMILY
ꤵ줿ͥåȥۥȤˤϡ
ᤵ줿ɥ쥹եߥΥͥåȥɥ쥹ʤ
.TP
.B EAI_AGAIN
͡ॵСŪʼ (temporary failure)
ֻ̣֤줿Ǥ⤦ٻƤߤ衣
.TP
.B EAI_BADFLAGS
.I ai_flags
Υե饰ʥե饰ޤޤƤ롣
.TP
.B EAI_FAIL
͡ॵС鹱Ūʼ (permanent failure)
ֻ̣֤줿
.TP
.B EAI_FAMILY
ᤵ줿ɥ쥹եߥݡȤƤʤ
.TP
.B EAI_MEMORY
꤬ʤ
.TP
.B EAI_NODATA
ꤵ줿ͥåȥۥȤ¸ߤ뤬
ͥåȥɥ쥹ҤȤĤƤʤ
.TP
.B EAI_NONAME
.I node
.I service
Τɤ餫ޤ
.I node
.I service
ξ NULL ä硢ޤ
.B AI_NUMERICSERV
.I hints.ai_flags
˻ꤵƤơ
.I hints.ai_flags
.I service
ͤΥݡֹʸǤʤ
.TP
.B EAI_SERVICE
ᤵ줿ӥϡᤵ줿åȥפǤѤǤʤ
¾ΥåȥפǤʤѲǽ⤷ʤ
.TP
.B EAI_SOCKTYPE
ᤵ줿åȥפݡȤƤʤ
.TP
.B EAI_SYSTEM
¾Υƥ२顼ܤ
.I errno
Ĵ٤뤳ȡ
.PP
.BR gai_strerror (3)
ؿѤȡΥ顼ɤʹ֤˲ɤʸѴǤΤǡ
顼Ŭ
.SH
POSIX.1-2001.
.BR getaddrinfo ()
ؿ RFC 2553 ˵ܤƤ롣
.SH
.BR AI_ADDRCONFIG ,
.BR AI_ALL ,
.B AI_V4MAPPED
glibc 2.3.3 ʹߤѲǽǤ롣
.B AI_NUMERICSERV
glibc 2.3.4 ʹߤѲǽǤ롣
.SH Ϣ
.BR getipnodebyaddr (3),
.BR getipnodebyname (3)
|