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
|
.\" 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
.\"
.\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
.\" Translated Sun Jan 14 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\"
.\"WORD: null pointer ̥롦ݥ
.\"
.TH getaddrinfo 3 "Dec 18, 2000" "Linux Man Page" "Linux Programmer's Manual"
.SH ̾
getaddrinfo \- ͥåȥΥɥ쥹ȥӥѴ
.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
δؿѤ
.B 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 ai_next
Сǥ줿
.B addrinfo
¤ΤΥꥹȤưŪƤˤäƺ
.I res
ˤƬؤΥݥꤹ롣
ʣ
.B 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 PF_INET
ޤ
.B PF_INET6
Τ줫˥åȤ)
.PP
.I hints
ѥˤϡͥ褵åȤΥ (뤤ϥץȥ)
ꤹ롣
.I hints
NULL
ˤ뤳ȤϡƤΥͥåȥɥ쥹/ץȥ뤬
ǽǤ뤳Ȥ̣롣
Υѥ
.B NULL
ǤʤȤϡ
.B addrinfo
¤ΤݥȤ褦ˤ롣
ι¤Τ
.IR ai_familiy ,
.IR ai_socktype ,
.I ai_protocol
Сǡͥ褵륽åȥפʤɤꤹ롣
.I ai_family
.B PF_UNSPEC
ꤹȡǤդΥץȥեߥ̣ (㤨 IPv4 IPv6)
.I ai_socktype
.I ai_protocol
0 ꤹȡ
ƱͤǤդΥåȥפץȥդ뤳Ȥ̣롣
.I ai_flags
Сˤɲåץꤹ (ϰʲ)
ʣΥե饰ꤹˤϡ OR ȤäƻꤹФ褤
.I hints
ѥΤ¾ΥСˤϡ
0 (ޤϥ̥롦ݥ) ʤФʤʤ
.PP
.I node
ѥ
.I service
ѥΤɤ餫 NULL ˤƤ褤 (ξƱˤԲ)
.I node
ˤϿͷΥͥåȥɥ쥹
(IPv4 ʤɥåȶڤ 10 ʷ
IPv6 ʤ 16 ʷ) 뤤ϥͥåȥۥȤ̾ꤹ롣
Ԥξϡ̾ƥͥåȥɥ쥹β褬Ǥɬפ롣
.I hints
ѥ
.I ai_flags
С
.B AI_NUMERICHOST
ե饰ޤޤƤϡ
.I node
ѥϿŪʥͥåȥɥ쥹ǤʤФʤʤ
.B AI_NUMERICHOST
ե饰ȤС
ۥȤ̾ɥ쥹Ĺ֤äƤޤǽӽǤ롣
.PP
.BR getaddrinfo (3)
ؿ
.B addrinfo
¤ΤΥꥹȤ뤬
Ǥγƥͥåȥɥ쥹
.I hints
ѥˤä줿¤˽Ȥˤʤ롣
.I hints
.B AI_CANONNAME
ե饰ޤޤƤˤϡ
.I ai_cannonname
ϥۥȤΥե̾ݥȤ褦ꤵ롣
.IR ai_family ,
.IR ai_socktype ,
.I ai_protocol
ƥСϥåΥѥꤹ롣
.I ai_addr
Сˤϥåȥɥ쥹ؤΥݥޤ졢
.I ai_addrlen
Сˤϥåȥɥ쥹Ĺ (Хñ) ޤ롣
.PP
.I node
NULL ξϡƥåȹ¤ΤΥͥåȥɥ쥹ν
.B AI_PASSIVE
ե饰˴Ťƽ
(Υե饰
.I hints
ѥ
.I ai_flags
Сꤵ)
.B AI_PASSIVE
ե饰åȤƤ顢
ƥåȹ¤ΤΥͥåȥɥ쥹ϻꤵʤޤޤˤʤ롣
ǤդΥͥåȥɥ쥹Υ饤³Ԥ褦
СץꥱѤ롣
.B AI_PASSIVE
ե饰åȤƤʤȡ
ͥåȥɥ쥹 loopback եɥ쥹ꤵ롣
ϸߤΥۥȾưƤ륵С³뤳ȤտޤƤ
饤ȥץꥱѤ롣
.PP
.I service
ϡƥåȹ¤ΤΥͥåȥɥ쥹Υݡֹꤹ롣
.I service
NULL ʤݡֹʤޤޤˤ롣
.PP
.BR freeaddrinfo (3)
ؿϡ
.I res
ݥȤꥹȤưŪ˳Ƥ줿롣
.SH ֤
.BR getaddrinfo (3)
0 ֤ԤȰʲ 0 Υ顼ɤΤ줫֤
.TP
.B EAI_FAMILY
ᤵ줿ɥ쥹եߥݡȤƤʤ
.TP
.B EAI_SOCKTYPE
ᤵ줿åȥפݡȤƤʤ
.TP
.B EAI_BADFLAGS
.I ai_flags
Υե饰
.TP
.B EAI_NONAME
.I node
뤤
.I service
Τ줫狼ʤ
.I node
.I service
ξ NULL ä⤳Υ顼֤롣
.TP
.B EAI_SERVICE
ᤵ줿ӥϡᤵ줿åȥפǤѤǤʤ
¾ΥåȥפǤʤѲǽ⤷ʤ
.TP
.B EAI_ADDRFAMILY
ꤵ줿ͥåȥۥȤϡ
ᤵ줿ɥ쥹եߥбͥåȥɥ쥹äƤʤ
.TP
.B EAI_NODATA
ꤵ줿ͥåȥۥȤ¸ߤ뤬
ͥåȥɥ쥹Ƥʤ
.TP
.B EAI_MEMORY
꤬ʤ
.TP
.B EAI_FAIL
͡ॵС鹱Ūʼ (permanent failure)
ֻ̣֤줿
.TP
.B EAI_AGAIN
͡ॵСŪʼ (temporary failure)
ֻ̣֤줿Ǥ⤦ٻƤߤ衣
.TP
.B EAI_SYSTEM
¾Υƥ२顼ܤ
.I errno
Ĵ٤뤳ȡ
.PP
.BR gai_strerror (3)
ؿѤȡΥ顼ɤʹ֤˲ɤʸѴǤΤǡ
顼Ŭ
.SH Ϣ
.BR getipnodebyname (3),
.BR getipnodebyaddr (3)
|