OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / getnameinfo.3
1 .\" This page is in the public domain.
2 .\" Almost all details are from RFC 2553.
3 .\"
4 .\" 2004-12-14, mtk, Added EAI_OVERFLOW error
5 .\" 2004-12-14 Fixed description of error return
6 .\"
7 .\" Translated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
8 .\" Updated 2007-01-07, Akihiro MOTOKI, LDP v2.43
9 .\" Updated 2008-08-11, Akihiro MOTOKI, LDP v3.05
10 .\" Updated 2010-04-10, Akihiro MOTOKI, LDP v3.24
11 .\"
12 .TH GETNAMEINFO 3 2009-12-03 "GNU" "Linux Programmer's Manual"
13 .\"O .SH NAME
14 .SH Ì¾Á°
15 .\"O getnameinfo \- address-to-name translation in protocol-independent manner
16 getnameinfo \- ¥¢¥É¥ì¥¹¤«¤é̾Á°¤Ø¤ÎÊÑ´¹¤ò¥×¥í¥È¥³¥ë¤Ë°Í¸¤·¤Ê¤¤¤«¤¿¤Á¤Ç¹Ô¤¦
17 .\"O .SH SYNOPSIS
18 .SH ½ñ¼°
19 .nf
20 .B #include <sys/socket.h>
21 .B #include <netdb.h>
22 .sp
23 .BI "int getnameinfo(const struct sockaddr *" "sa" ", socklen_t " "salen" ,
24 .BI "                char *" "host" ", size_t " "hostlen" ,
25 .BI "                char *" "serv" ", size_t " "servlen" ", int " "flags" );
26 .fi
27 .sp
28 .in -4n
29 .\"O Feature Test Macro Requirements for glibc (see
30 .\"O .BR feature_test_macros (7)):
31 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
32 .RB ( feature_test_macros (7)
33 »²¾È):
34 .ad l
35 .in
36 .sp
37 .BR getnameinfo ():
38 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
39 .ad b
40 .\"O .SH DESCRIPTION
41 .SH ÀâÌÀ
42 .\"O The
43 .\"O .BR getnameinfo ()
44 .\"O function is the inverse of
45 .\"O .BR getaddrinfo (3):
46 .\"O it converts a socket address to a corresponding host and service,
47 .\"O in a protocol-independent manner.
48 .\"O It combines the functionality of
49 .\"O .BR gethostbyaddr (3)
50 .\"O and
51 .\"O .BR getservbyport (3),
52 .\"O but unlike those functions,
53 .\"O .BR getaddrinfo (3)
54 .\"O is reentrant and allows programs to eliminate
55 .\"O IPv4-versus-IPv6 dependencies.
56 .BR getnameinfo ()
57 ´Ø¿ô¤Ï¡¢
58 .BR getaddrinfo (3)
59 ¤ÎµÕ¤ÎÆ°ºî¤ò¹Ô¤¦¡£¤Ä¤Þ¤ê¡¢¥×¥í¥È¥³¥ë¤Ë°Í¸¤·¤Ê¤¤¤«¤¿¤Á¤Ç
60 ¥½¥±¥Ã¥È¥¢¥É¥ì¥¹¤«¤éÂбþ¤¹¤ë¥Û¥¹¥È̾¤È¥µ¡¼¥Ó¥¹¤Ø¤ÎÊÑ´¹¤ò¹Ô¤¦¡£
61 ¤³¤Î´Ø¿ô¤Ï
62 .BR gethostbyaddr (3)
63 ¤È
64 .BR getservbyport (3)
65 ¤Îµ¡Ç½¤ò°ì¤Ä¤Ë¤·¤¿¤â¤Î¤À¤¬¡¢
66 ¤³¤ì¤é¤Î´Ø¿ô¤È°ã¤¤¡¢
67 .BR getnameinfo (3)
68 ¤Ï¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤¢¤ê¡¢IPv4 ¤È IPv6 ¤Îº¹Ê¬¤Ë°Í¸¤·¤Ê¤¤¤«¤¿¤Á¤Ç
69 ¥×¥í¥°¥é¥à¤ò½ñ¤¯¤³¤È¤¬¤Ç¤­¤ë¡£
70
71 .\"O The
72 .\"O .I sa
73 .\"O argument is a pointer to a generic socket address structure
74 .\"O (of type
75 .\"O .I sockaddr_in
76 .\"O or
77 .\"O .IR sockaddr_in6 )
78 .\"O of size
79 .\"O .I salen
80 .\"O that holds the input IP address and port number.
81 .I sa
82 °ú¤­¿ô¤Ï¡¢
83 IP ¥¢¥É¥ì¥¹¤È¥Ý¡¼¥ÈÈÖ¹æ¤Î¾ðÊó¤òÊÝ»ý¤·¤Æ¤¤¤ë
84 ÈÆÍÑŪ¤Ê¥½¥±¥Ã¥È¥¢¥É¥ì¥¹¹½Â¤ÂÎ
85 .RI ( sockaddr_in
86 ·¿¤Þ¤¿¤Ï
87 .I sockaddr_in6
88 ·¿) ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
89 .I salen
90 ¤Ï
91 .I sa
92 ¤Î¥µ¥¤¥º¤Ç¤¢¤ë¡£
93 .\"O The arguments
94 .\"O .I host
95 .\"O and
96 .\"O .I serv
97 .\"O are pointers to caller-allocated buffers (of size
98 .\"O .I hostlen
99 .\"O and
100 .\"O .I servlen
101 .\"O respectively) into which
102 .\"O .BR getnameinfo ()
103 .\"O places null-terminated strings containing the host and
104 .\"O service names respectively.
105 .I host
106 ¤È
107 .I serv
108 °ú¤­¿ô¤Ï¡¢(¤½¤ì¤¾¤ì¥µ¥¤¥º¤¬
109 .I hostlen
110 ¤È
111 .I servlen
112 ¤Î) ¸Æ¤Ó½Ð¤·Â¦¤Ç³ÎÊݤµ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ê¡¢
113 ¥Û¥¹¥È̾¤È¥µ¡¼¥Ó¥¹Ì¾¤ò´Þ¤à NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤¬
114 ¤½¤ì¤¾¤ì¤Î¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£
115
116 .\"O The caller can specify that no hostname (or no service name)
117 .\"O is required by providing a NULL
118 .\"O .I host
119 .\"O (or
120 .\"O .IR serv )
121 .\"O argument or a zero
122 .\"O .I hostlen
123 .\"O (or
124 .\"O .IR servlen )
125 .\"O argument.
126 .\"O However, at least one of hostname or service name
127 .\"O must be requested.
128 ¥Û¥¹¥È̾¤¬ÉÔÍפǤ¢¤ë¤³¤È¤ò¤³¤Î´Ø¿ô¤ËÅÁ¤¨¤ë¤Ë¤Ï¡¢
129 .I host
130 ¤Ë NULL ¤ò»ØÄꤹ¤ë¤«¡¢
131 .I hostlen
132 ¤Ë 0 ¤ò»ØÄꤹ¤ë¡£Æ±Íͤˡ¢¥µ¡¼¥Ó¥¹Ì¾¤¬ÉÔÍפʾì¹ç¤Ï¡¢
133 .I serv
134 ¤Ë NULL ¤ò»ØÄꤹ¤ë¤«¡¢
135 .I servlen
136 ¤Ë 0 ¤ò»ØÄꤹ¤ë¡£
137 ¤·¤«¤·¡¢¥Û¥¹¥È̾¤È¥µ¡¼¥Ó¥¹Ì¾¤ÎξÊý¤òÉÔÍפÀ¤È»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤
138 (¤¤¤º¤ì¤«°ìÊý¤ÏÍ׵᤹¤ë¤³¤È)¡£
139
140 .\"O The
141 .\"O .I flags
142 .\"O argument modifies the behavior of
143 .\"O .BR getnameinfo ()
144 .\"O as follows:
145 .I flags
146 °ú¤­¿ô¤Ç
147 .BR getnameinfo ()
148 ¤ÎÆ°ºî¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£»ØÄê¤Ç¤­¤ëÃͤϰʲ¼¤ÎÄ̤ê:
149 .TP
150 .B NI_NAMEREQD
151 .\"O If set, then an error is returned if the hostname cannot be determined.
152 »ØÄꤹ¤ë¤È¡¢¥Û¥¹¥È̾¤¬·èÄê¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¥¨¥é¡¼¤òÊÖ¤¹¡£
153 .TP
154 .B NI_DGRAM
155 .\"O If set, then the service is datagram (UDP) based rather than
156 .\"O stream (TCP) based.
157 .\"O This is required for the few ports (512-514)
158 .\"O that have different services for UDP and TCP.
159 »ØÄꤹ¤ë¤È¡¢¥¹¥È¥ê¡¼¥à¥Ù¡¼¥¹ (TCP) ¤Ç¤Ê¤¯¥Ç¡¼¥¿¥°¥é¥à¥Ù¡¼¥¹ (UDP)
160 ¤Î¥µ¡¼¥Ó¥¹¤òÂоݤˤ¹¤ë¡£¿ô¤Ï¾¯¤Ê¤¤¤¬¡¢
161 UDP ¤È TCP ¤Ç°ã¤¦¥µ¡¼¥Ó¥¹¤òÄ󶡤·¤Æ¤¤¤ë¥Ý¡¼¥È
162 (512-514) ¤ËÂФ·¤ÆɬÍפȤʤ롣
163 .TP
164 .B NI_NOFQDN
165 .\"O If set, return only the hostname part of the fully qualified domain name
166 .\"O for local hosts.
167 »ØÄꤹ¤ë¤È¡¢¥í¡¼¥«¥ë¤Ê¥Û¥¹¥È¤Ë¤Ï fully qualified domain name (FQDN) ¤Î
168 ¥Û¥¹¥È̾¤ÎÉôʬ¤Î¤ß¤òÊÖ¤¹¡£
169 .TP
170 .B NI_NUMERICHOST
171 .\"O If set, then the numeric form of the hostname is returned.
172 .\"O .\" For example, by calling
173 .\"O .\" .BR inet_ntop ()
174 .\"O .\" instead of
175 .\"O .\" .BR gethostbyaddr ().
176 .\"O (When not set, this will still happen in case the node's name
177 .\"O cannot be determined.)
178 »ØÄꤹ¤ë¤È¡¢¿ôÃÍ·Á¼°¤Î¥Û¥¹¥È̾¤¬ÊÖ¤µ¤ì¤ë¡£
179 .\" Î㤨¤Ð
180 .\" .BR gethostbyaddr ()
181 .\" ¤ÎÂå¤ï¤ê¤Ë
182 .\" .BR inet_ntop ()
183 .\" ¤ò¸Æ¤Ö
184 (»ØÄꤷ¤Ê¤¯¤Æ¤â¡¢¥Î¡¼¥É¤Î̾Á°¤¬·èÄê¤Ç¤­¤Ê¤¤¾ì¹ç¤Ï¿ôÃÍ·Á¼°¤¬Ê֤뤳¤È¤¬¤¢¤ë)¡£
185 .\" POSIX.1-2003 has NI_NUMERICSCOPE, but glibc doesn't have it.
186 .TP
187 .B NI_NUMERICSERV
188 .\"O If set, then the numeric form of the service address is returned.
189 .\"O (When not set, this will still happen in case the service's name
190 .\"O cannot be determined.)
191 »ØÄꤹ¤ë¤È¡¢¿ôÃÍ·Á¼°¤Î¥µ¡¼¥Ó¥¹Ì¾ (Î㤨¤Ð¥Ý¡¼¥ÈÈÖ¹æ) ¤¬ÊÖ¤µ¤ì¤ë
192 (»ØÄꤷ¤Ê¤¯¤Æ¤â¡¢¥µ¡¼¥Ó¥¹Ì¾¤¬·èÄê¤Ç¤­¤Ê¤¤¾ì¹ç¤Ï¿ôÃÍ·Á¼°¤¬Ê֤뤳¤È¤¬¤¢¤ë)¡£
193 .\"O .SS "Extensions to getaddrinfo() for Internationalized Domain Names"
194 .SS "¹ñºÝ²½¥É¥á¥¤¥ó̾¤Î¤¿¤á¤Î getnameinfo() ¤Î³ÈÄ¥"
195 .\"O motoki: ¸¶Ê¸¤Î getaddrinfo() ¤Ï getnameinfo() ¤Î´Ö°ã¤¤¤È»×¤ï¤ì¤ë¡£
196 .PP
197 .\"O Starting with glibc 2.3.4,
198 .\"O .BR getnameinfo ()
199 .\"O has been extended to selectively allow
200 .\"O hostnames to be transparently converted to and from the
201 .\"O Internationalized Domain Name (IDN) format (see RFC 3490,
202 .\"O .IR "Internationalizing Domain Names in Applications (IDNA)" ).
203 .\"O Three new flags are defined:
204 glibc 2.3.4 ¤«¤é¡¢
205 .BR getnameinfo ()
206 ¤Ë³ÈÄ¥¤¬¹Ô¤ï¤ì¡¢¥Û¥¹¥È̾¤È
207 ¹ñºÝ²½¥É¥á¥¤¥ó̾ (Internationalized Domain Name; IDN) ·Á¼°¤È¤Î´Ö¤Ç
208 Æ©²áŪ¤ÊÊÑ´¹¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë
209 (IDN ·Á¼°¤Ë¤Ä¤¤¤Æ¤Ï RFC 3490 ¤Î
210 .I "Internationalizing Domain Names in Applications (IDNA)"
211 ¤ò»²¾È)¡£3¤Ä¤Î¥Õ¥é¥°¤¬¿·¤¿¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
212 .TP
213 .B NI_IDN
214 .\"O If this flag is used, then the name found in the lookup process is
215 .\"O converted from IDN format to the locale's encoding if necessary.
216 .\"O ASCII-only names are not affected by the conversion, which
217 .\"O makes this flag usable in existing programs and environments.
218 ¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢É¬ÍפǤ¢¤ì¤Ð¡¢¸¡º÷½èÍý¤Ç¸«¤Ä¤«¤Ã¤¿Ì¾Á°¤Ï
219 IDN ·Á¼°¤«¤é¥í¥±¡¼¥ë¤Ë±þ¤¸¤¿Éä¹æ²½·Á¼°¤ËÊÑ´¹¤µ¤ì¤ë¡£
220 ASCII Ê¸»ú¤À¤±¤Î̾Á°¤Ï¤³¤ÎÊÑ´¹¤Ç¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£¤³¤Î¤¿¤á¡¢
221 ´û¸¤Î¥×¥í¥°¥é¥à¤ä´Ä¶­¤Ç¤³¤Î¥Õ¥é¥°¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
222 .TP
223 .BR NI_IDN_ALLOW_UNASSIGNED ", " NI_IDN_USE_STD3_ASCII_RULES
224 .\"O Setting these flags will enable the
225 .\"O IDNA_ALLOW_UNASSIGNED (allow unassigned Unicode code points) and
226 .\"O IDNA_USE_STD3_ASCII_RULES (check output to make sure it is a STD3
227 .\"O conforming host name)
228 .\"O flags respectively to be used in the IDNA handling.
229 ¤³¤ì¤é¤Î¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¤È¡¢IDNA ½èÍý¤Ç»ÈÍѤµ¤ì¤ë¥Õ¥é¥°
230 IDNA_ALLOW_UNASSIGNED (̤³ä¤êÅö¤Æ¤Î Unicode ¤Î¥³¡¼¥É¥Ý¥¤¥ó¥È¤òµöÍÆ) ¤È
231 IDNA_USE_STD3_ASCII_RULES (½ÐÎϤ¬ STD3 ½àµò¤Î¥Û¥¹¥È̾¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë)
232 ¤¬¤½¤ì¤¾¤ìÍ­¸ú¤Ë¤Ê¤ë¡£
233 .\"O .SH "RETURN VALUE"
234 .SH ÊÖ¤êÃÍ
235 .\" FIXME glibc defines the following additional errors, some which
236 .\" can probably be returned by getnameinfo(); they need to
237 .\" be documented.
238 .\" #ifdef __USE_GNU
239 .\" #define EAI_INPROGRESS  -100  /* Processing request in progress.  */
240 .\" #define EAI_CANCELED    -101  /* Request canceled.  */
241 .\" #define EAI_NOTCANCELED -102  /* Request not canceled.  */
242 .\" #define EAI_ALLDONE     -103  /* All requests done.  */
243 .\" #define EAI_INTR        -104  /* Interrupted by a signal.  */
244 .\" #define EAI_IDN_ENCODE  -105  /* IDN encoding failed.  */
245 .\" #endif
246 .\"O On success 0 is returned, and node and service names, if requested,
247 .\"O are filled with null-terminated strings, possibly truncated to fit
248 .\"O the specified buffer lengths.
249 .\"O On error one of the following nonzero error codes is returned:
250 À®¸ù¤¹¤ë¤È 0 ¤¬Ê֤ꡢ(Í׵ᤵ¤ì¤Æ¤¤¤ì¤Ð) ¥Î¡¼¥É¤È¥µ¡¼¥Ó¥¹¤Î̾Á°¤¬
251 NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤Î·Á¼°¤Ç¤½¤ì¤¾¤ì¤Î»ØÄê¥Ð¥Ã¥Õ¥¡¤ËÊÖ¤µ¤ì¤ë
252 (¥Ð¥Ã¥Õ¥¡¤ÎŤµ¤Ë¤¢¤¦¤è¤¦¤Ë½Ì¤á¤é¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤)¡£
253 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï¡¢°Ê²¼¤Î 0 °Ê³°¤Î¥¨¥é¡¼¡¦¥³¡¼¥É¤¬ÊÖ¤µ¤ì¤ë:
254 .TP
255 .B EAI_AGAIN
256 .\"O The name could not be resolved at this time.
257 .\"O Try again later.
258 »ØÄꤵ¤ì¤¿Ì¾Á°¤¬¸½»þÅÀ¤Ç¤Ï²ò·è¤Ç¤­¤Ê¤«¤Ã¤¿¡£
259 ¸å¤ÇºÆ»î¹Ô¤·¤Æ¤ß¤ë¤³¤È¡£
260 .TP
261 .B EAI_BADFLAGS
262 .\"O The
263 .\"O .I flags
264 .\"O argument has an invalid value.
265 .I flags
266 °ú¤­¿ô¤ËÉÔÀµ¤ÊÃͤ¬Í¿¤¨¤é¤ì¤¿¡£
267 .TP
268 .B EAI_FAIL
269 .\"O A nonrecoverable error occurred.
270 ²óÉü¤Ç¤­¤Ê¤¤¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
271 .TP
272 .B EAI_FAMILY
273 .\"O The address family was not recognized,
274 .\"O or the address length was invalid for the specified family.
275 »ØÄꤷ¤¿¥¢¥É¥ì¥¹¥Õ¥¡¥ß¥ê¡¼¤¬Ç§¼±¤Ç¤­¤Ê¤«¤Ã¤¿¡£
276 ¤¢¤ë¤¤¤Ï¥¢¥É¥ì¥¹¤ÎŤµ¤¬»ØÄꤵ¤ì¤¿¥Õ¥¡¥ß¥ê¡¼¤Ë¹ç¤¦¤â¤Î¤Ç¤Ê¤«¤Ã¤¿¡£
277 .TP
278 .B EAI_MEMORY
279 .\"O Out of memory.
280 ¥á¥â¥ê¤¬Â­¤ê¤Ê¤¤¡£
281 .TP
282 .B EAI_NONAME
283 .\"O The name does not resolve for the supplied arguments.
284 .\"O .B NI_NAMEREQD
285 .\"O is set and the host's name cannot be located,
286 .\"O or neither hostname nor service name were requested.
287 Í¿¤¨¤é¤ì¤¿¥Ñ¥é¥á¡¼¥¿¤Ç¤Ï̾Á°¤¬²ò·è¤Ç¤­¤Ê¤¤¡£
288 .B NI_NAMEREQD
289 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤¿¤¬¥Û¥¹¥È̾¤¬·èÄê¤Ç¤­¤Ê¤«¤Ã¤¿¤«¡¢
290 ¥Û¥¹¥È̾¤â¥µ¡¼¥Ó¥¹Ì¾¤âÍ׵ᤵ¤ì¤Ê¤«¤Ã¤¿¡£
291 .TP
292 .B EAI_OVERFLOW
293 .\"O The buffer pointed to by
294 .\"O .I host
295 .\"O or
296 .\"O .I serv
297 .\"O was too small.
298 .I host
299 ¤Þ¤¿¤Ï
300 .I serv
301 ¤¬»Ø¤·¤Æ¤¤¤ë¥Ð¥Ã¥Õ¥¡¤¬¾®¤µ¤¹¤®¤¿¡£
302 .TP
303 .B EAI_SYSTEM
304 .\"O A system error occurred.
305 .\"O The error code can be found in
306 .\"O .IR errno .
307 ¥·¥¹¥Æ¥à¥¨¥é¡¼¤¬µ¯¤Ã¤¿¡£
308 ¥¨¥é¡¼¥³¡¼¥É¤Ï
309 .I errno
310 ¤ËÀßÄꤵ¤ì¤ë¡£
311 .PP
312 .\"O The
313 .\"O .BR gai_strerror (3)
314 .\"O function translates these error codes to a human readable string,
315 .\"O suitable for error reporting.
316 .BR gai_strerror (3)
317 ´Ø¿ô¤ò»È¤¦¤È¡¢¤³¤ì¤é¤Î¥¨¥é¡¼¡¦¥³¡¼¥É¤ò¡¢¥¨¥é¡¼¡¦¥ì¥Ý¡¼¥È¤ËŬ¤·¤¿
318 ¿Í´Ö¤¬Æɤߤ䤹¤¤Ê¸»úÎó¤ËËÝÌõ¤·¤Æ¤¯¤ì¤ë¡£
319 .\"O .SH FILES
320 .SH ¥Õ¥¡¥¤¥ë
321 /etc/hosts
322 .br
323 /etc/nsswitch.conf
324 .br
325 /etc/resolv.conf
326 .\"O .SH VERSIONS
327 .SH ¥Ð¡¼¥¸¥ç¥ó
328 .\"O .BR getnameinfo ()
329 .\"O is provided in glibc since version 2.1.
330 .BR getnameinfo ()
331 ¤Ï¡¢glibc ¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
332 .\"O .SH "CONFORMING TO"
333 .SH ½àµò
334 RFC\ 2553, POSIX.1-2001.
335 .\"O .SH NOTES
336 .SH Ãí°Õ
337 .\"O In order to assist the programmer in choosing reasonable sizes
338 .\"O for the supplied buffers,
339 .\"O .I <netdb.h>
340 .\"O defines the constants
341 ŬÀڤʥХåե¡¥µ¥¤¥º¤òÁªÂò¤Ç¤­¤ë¤è¤¦¤Ë¡¢
342 .I <netdb.h>
343 ¤Ë°Ê²¼¤ÎÄê¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
344 .in +4n
345 .nf
346
347 #define NI_MAXHOST      1025
348 #define NI_MAXSERV      32
349 .fi
350 .in
351
352 .\"O Since glibc 2.8,
353 .\"O these definitions are exposed only if one of the feature test macros
354 .\"O .BR _BSD_SOURCE ,
355 .\"O .BR _SVID_SOURCE ,
356 .\"O or
357 .\"O .BR _GNU_SOURCE
358 .\"O is defined.
359 glibc 2.8 °Ê¹ß¤Ç¤Ï¡¢µ¡Ç½¸¡ºº¥Þ¥¯¥í
360 .BR _BSD_SOURCE ,
361 .BR _SVID_SOURCE ,
362 .BR _GNU_SOURCE
363 ¤Î¤¤¤º¤ì¤«¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë¤Î¤ß¡¢¤³¤ì¤é¤ÎÄêµÁ¤¬¸ø³«¤µ¤ì¤ë¡£
364 .PP
365 .\"O The former is the constant
366 .\"O .B MAXDNAME
367 .\"O in recent versions of BIND's
368 .\"O .I <arpa/nameser.h>
369 .\"O header file.
370 .\"O The latter is a guess based on the services listed
371 .\"O in the current Assigned Numbers RFC.
372 Á°¼Ô¤Ï¡¢ºÇ¶á¤Î¥Ð¡¼¥¸¥ç¥ó¤Î BIND ¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë
373 .I <arpa/nameser.h>
374 Ãæ¤ÎÄê¿ô
375 .B MAXDNAME
376 ¤ÈƱ¤¸ÃͤǤ¢¤ë¡£
377 ¸å¼Ô¤Ï¡¢³ä¤êÅö¤ÆºÑ¤Î¿ôÃͤˤĤ¤¤Æµ­¤·¤¿¸½ºß¤Î RFC ¤Ë
378 Îóµó¤µ¤ì¤Æ¥µ¡¼¥Ó¥¹¤«¤é¿äÎ̤·¤¿ÃͤǤ¢¤ë¡£
379 .\"O .SH EXAMPLE
380 .SH Îã
381 .\"O The following code tries to get the numeric hostname and service name,
382 .\"O for a given socket address.
383 .\"O Note that there is no hardcoded reference to
384 .\"O a particular address family.
385 °Ê²¼¤Î¥³¡¼¥É¤Ï¡¢»ØÄꤵ¤ì¤¿¥½¥±¥Ã¥È¥¢¥É¥ì¥¹¤ËÂФ¹¤ë
386 ¥Û¥¹¥È¤È¥µ¡¼¥Ó¥¹¤Î¿ôÃÍɽ¼°¤ò¼èÆÀ¤·¤è¤¦¤È»î¤ß¤ë¡£
387 ÆÃÄê¤Î¥¢¥É¥ì¥¹¥Õ¥¡¥ß¥ê¡¼¤ËÂФ¹¤ë»²¾È¾ðÊó¤Ï
388 °ìÀڥϡ¼¥É¥³¡¼¥É¤µ¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤ËÃåÌܤ·¤Æ¤Û¤·¤¤¡£
389
390 .in +4n
391 .nf
392 struct sockaddr *sa;    /* input */
393 socklen_t len;          /* input */
394 char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
395
396 if (getnameinfo(sa, len, hbuf, sizeof(hbuf), sbuf,
397             sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
398     printf("host=%s, serv=%s\en", hbuf, sbuf);
399 .fi
400 .in
401
402 .\"O The following version checks if the socket address has a
403 .\"O reverse address mapping.
404 °Ê²¼¤Ç¤Ï¥½¥±¥Ã¥È¥¢¥É¥ì¥¹¤Ë
405 µÕ¸þ¤­¤Î¥¢¥É¥ì¥¹¥Þ¥Ã¥Ô¥ó¥°¤¬Â¸ºß¤¹¤ë¤«¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¤¤ë¡£
406
407 .in +4n
408 .nf
409 struct sockaddr *sa;    /* input */
410 socklen_t len;          /* input */
411 char hbuf[NI_MAXHOST];
412
413 if (getnameinfo(sa, len, hbuf, sizeof(hbuf),
414             NULL, 0, NI_NAMEREQD))
415     printf("could not resolve hostname");
416 else
417     printf("host=%s\en", hbuf);
418 .fi
419 .in
420 .PP
421 .\"O An example program using
422 .\"O .BR getnameinfo ()
423 .\"O can be found in
424 .\"O .BR getaddrinfo (3).
425 .BR getnameinfo ()
426 ¤ò»È¤Ã¤¿¥×¥í¥°¥é¥àÎ㤬
427 .BR getaddrinfo (3)
428 ¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£
429 .\"O .SH "SEE ALSO"
430 .SH ´ØÏ¢¹àÌÜ
431 .BR accept (2),
432 .BR getpeername (2),
433 .BR getsockname (2),
434 .BR recvfrom (2),
435 .BR socket (2),
436 .BR getaddrinfo (3),
437 .BR gethostbyaddr (3),
438 .BR getservbyname (3),
439 .BR getservbyport (3),
440 .BR inet_ntop (3),
441 .BR hosts (5),
442 .BR services (5),
443 .BR hostname (7),
444 .BR named (8)
445 .LP
446 R. Gilligan, S. Thomson, J. Bound and W. Stevens,
447 .IR "Basic Socket Interface Extensions for IPv6" ,
448 RFC\ 2553, March 1999.
449 .LP
450 Tatsuya Jinmei and Atsushi Onoe,
451 .IR "An Extension of Format for IPv6 Scoped Addresses" ,
452 internet draft, work in progress.
453 ftp://ftp.ietf.org/internet\-drafts/draft\-ietf\-ipngwg\-scopedaddr\-format\-02.txt
454 .LP
455 Craig Metz,
456 .IR "Protocol Independence Using the Sockets API" ,
457 Proceedings of the freenix track:
458 2000 USENIX annual technical conference, June 2000.
459 http://www.usenix.org/publications/library/proceedings/usenix2000/freenix/metzprotocol.html