OSDN Git Service

38e814a305eb7756f85c17f94805e4e3c0f3ae3c
[linuxjm/LDP_man-pages.git] / release / man3 / inet.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
5 .\"     <mtk.manpages@gmail.com>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .\" References consulted:
28 .\"     Linux libc source code
29 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
30 .\"     386BSD man pages
31 .\"     libc.info (from glibc distribution)
32 .\" Modified Sat Jul 24 19:12:00 1993 by Rik Faith <faith@cs.unc.edu>
33 .\" Modified Sun Sep  3 20:29:36 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
34 .\" Changed network into host byte order (for inet_network),
35 .\"     Andreas Jaeger <aj@arthur.rhein-neckar.de>, 980130.
36 .\" 2008-06-19, mtk
37 .\"     Describe the various address forms supported by inet_aton().
38 .\"     Clarify discussion of inet_lnaof(), inet_netof(), and inet_makeaddr().
39 .\"     Add discussion of Classful Addressing, noting that it is obsolete.
40 .\"     Added an EXAMPLE program.
41 .\"
42 .\" Japanese Version Copyright (c) 1998 Ueyama Rui
43 .\"         all rights reserved.
44 .\" Translated 1998-05-23, Ueyama Rui <rui@linux.or.jp>
45 .\" Updated & Modefied 1999-02-26, Shouichi Saito
46 .\" Updated 1999-12-26, Kentaro Shirakata <argrath@ub32.org>
47 .\" Updated 2005-10-04, Kentaro Shirakata <argrath@ub32.org>
48 .\" Updated 2007-05-01, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.46
49 .\" Updated 2008-08-13, Akihiro MOTOKI, LDP v3.05
50 .\"
51 .\"WORD:        numbers-and-dots notation       ¿ôÃͤȥɥåȤˤè¤ëµ­Ë¡
52 .\"WORD:        dotted-decimal notation ¥É¥Ã¥È¶èÀÚ¤ê¤Î 10 ¿Ê¿ôµ­Ë¡
53 .\"WORD:        feature test macro      µ¡Ç½¸¡ºº¥Þ¥¯¥í
54 .\"
55 .TH INET 3  2008-06-19 "GNU" "Linux Programmer's Manual"
56 .SH Ì¾Á°
57 inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof,
58 inet_netof \- ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹Áàºî¥ë¡¼¥Á¥ó
59 .SH ½ñ¼°
60 .nf
61 .B #include <sys/socket.h>
62 .B #include <netinet/in.h>
63 .B #include <arpa/inet.h>
64 .sp
65 .BI "int inet_aton(const char *" cp ", struct in_addr *" inp );
66 .sp
67 .BI "in_addr_t inet_addr(const char *" cp );
68 .sp
69 .BI "in_addr_t inet_network(const char *" cp );
70 .sp
71 .BI "char *inet_ntoa(struct in_addr " in );
72 .sp
73 .BI "struct in_addr inet_makeaddr(int " net ", int " host );
74 .sp
75 .BI "in_addr_t inet_lnaof(struct in_addr " in );
76 .sp
77 .BI "in_addr_t inet_netof(struct in_addr " in );
78 .fi
79 .sp
80 .in -4n
81 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
82 .RB ( feature_test_macros (7)
83 »²¾È):
84 .in
85 .sp
86 .BR inet_aton (),
87 .BR inet_ntoa ():
88 _BSD_SOURCE || _SVID_SOURCE
89 .SH ÀâÌÀ
90 .BR inet_aton ()
91 ¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¤Î¥¢¥É¥ì¥¹ \fIcp\fP ¤ò¡¢
92 IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­¤«¤é (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥Ð¥¤¥Ê¥êÃͤØ
93 ÊÑ´¹¤·¡¢ÊÑ´¹·ë²Ì¤ò \fIinp\fP ¤¬»Ø¤·¤Æ¤¤¤ë¹½Â¤ÂΤ˳ÊǼ¤¹¤ë¡£
94 ¥¢¥É¥ì¥¹¤¬Í­¸ú¤Ê¾ì¹ç 0 °Ê³°¤òÊÖ¤·¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï 0 ¤òÊÖ¤¹¡£
95 .I cp
96 ¤ÇÅϤ¹¥¢¥É¥ì¥¹¤È¤·¤Æ¡¢°Ê²¼¤Î·Á¼°¤òÍѤ¤¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
97 .TP 10
98 .I a.b.c.d
99 4 ¤Ä¤Î¿ô»ú¤Î¤½¤ì¤¾¤ì¤Ï¥¢¥É¥ì¥¹¤Î³Æ¥Ð¥¤¥È¤ò¼¨¤¹¡£
100 ¤³¤ì¤é¤Î¥Ð¥¤¥È¤Ïº¸¤«¤é±¦¤Î½ç½ø¤Ç¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤Ë³ä¤êÅö¤Æ¤é¤ì¤ë¡£
101 .TP
102 .I a.b.c
103 .I a
104 ¤È
105 .I b
106 ¤Ï¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤ÎºÇ½é¤Î 2 ¥Ð¥¤¥È¤ò¼¨¤¹¡£
107 .I c
108 ¤Ï 16 ¥Ó¥Ã¥ÈÃͤȲò¼á¤µ¤ì¡¢¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤Î±¦Â¦¤Î 2 ¥Ð¥¤¥È¤òɽ¤¹¡£
109 ¤³¤Îɽµ­¤Ï¡¢(²áµî¤Î¤â¤Î¤È¤Ê¤Ã¤¿) ¥¯¥é¥¹ B ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤ò
110 »ØÄꤹ¤ë¤Î¤ËŬ¤·¤Æ¤¤¤ë¡£
111 .TP
112 .I a.b
113 .I a
114 ¤Ï¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤ÎºÇ½é¤Î¥Ð¥¤¥È¤ò¼¨¤¹¡£
115 .I b
116 ¤Ï 24 ¥Ó¥Ã¥ÈÃͤȲò¼á¤µ¤ì¡¢¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤Î±¦Â¦¤Î 3 ¥Ð¥¤¥È¤òɽ¤¹¡£
117 ¤³¤Îɽµ­¤Ï¡¢(²áµî¤Î¤â¤Î¤È¤Ê¤Ã¤¿) ¥¯¥é¥¹ C ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤ò
118 »ØÄꤹ¤ë¤Î¤ËŬ¤·¤Æ¤¤¤ë¡£
119 .TP
120 .I a
121 ÃÍ
122 .I a
123 ¤Ï 32 ¥Ó¥Ã¥ÈÃͤȲò¼á¤µ¤ì¡¢¥Ð¥¤¥È¤ÎºÆÇÛÃ֤ϹԤï¤ì¤º¡¢
124 ¤½¤Î¤Þ¤Þ¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤È¤·¤Æ³ÊǼ¤µ¤ì¤ë¡£
125 .PP
126 ¾åµ­¤ÎÁ´¤Æ¤Î·Á¼°¤Ç¡¢¥É¥Ã¥È¶èÀÚ¤ê¤Î¥¢¥É¥ì¥¹¤Î³ÆÍ×ÁǤϡ¢10 ¿Ê¿ô¡¢
127 8 ¿Ê¿ô (ÀèƬ¤Ë
128 .I 0
129 ¤òÉÕ¤±¤ë)¡¢
130 16 ¿Ê¿ô (ÀèƬ¤Ë
131 .I 0X
132 ¤òÉÕ¤±¤ë) ¤Ç»ØÄê¤Ç¤­¤ë¡£
133 ¤³¤ì¤é¤Î·Á¼°¤Î¥¢¥É¥ì¥¹¤ò¤Þ¤È¤á¤Æ
134 .I "IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­ (IPv4 numbers-and-dots notation)"
135 ¤È¸Æ¤Ö¡£
136 ¤Þ¤¿¡¢10 ¿Ê¿ô 4 ¤Ä¤À¤±¤ò»È¤Ã¤¿·Á¼°¤ò
137 .I "IPv4 ¤Î¥É¥Ã¥È¶èÀÚ¤ê¤Î 10 ¿Ê¿ôɽµ­ (IPv4 dotted-decimal notation)"
138 ¤È¸Æ¤Ö
139 .RI ( "IPv4 ¤Î¥É¥Ã¥È¶èÀÚ¤ê 4 Ê¬³äɽµ­ (IPv4 dotted-decimal notation)"
140 ¤È¸Æ¤Ö¤³¤È¤â¤¢¤ë)¡£
141 .PP
142 .BR inet_addr ()
143 ´Ø¿ô¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¤Î¥¢¥É¥ì¥¹ \fIcp\fP ¤ò¡¢
144 IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­¤«¤é¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤Î
145 ¥Ð¥¤¥Ê¥êÃͤØÊÑ´¹¤·¤ÆÊÖ¤¹¡£
146 ÆþÎϤ¬ÉÔÀµ¤Ê¾ì¹ç¡¢
147 .B INADDR_NONE
148 (ÉáÄ̤Ϡ\-1) ¤òÊÖ¤¹¡£
149 \-1 ¤ÏÍ­¸ú¤Ê¥¢¥É¥ì¥¹ (255.255.255.255) ¤Ê¤Î¤Ç¡¢¤³¤Î´Ø¿ô¤ò»È¤¦¤È
150 ÌäÂê¤Ë¤Ê¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
151 ¤³¤Î´Ø¿ô¤ò»È¤¦¤Î¤ÏÈò¤±¡¢Âå¤ï¤ê¤Ë
152 .BR inet_aton (),
153 .BR inet_pton (3),
154 .BR getaddrinfo (3)
155 ¤ò»È¤¦¤Î¤¬¤è¤¤¡£
156 ¤³¤ì¤é¤Î´Ø¿ô¤ÎÊý¤¬¡¢¥¨¥é¡¼¤ÎÄÌÃΤ¬¤è¤ê¤­¤ì¤¤¤ÊÊýË¡¤Ç¹Ô¤ï¤ì¤ë¡£
157 .PP
158 .BR inet_network ()
159 ´Ø¿ô¤Ï¡¢
160 IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­¤Îʸ»úÎó \fIcp\fP ¤ò¡¢
161 ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹¤È¤·¤Æ¤Î»ÈÍѤËŬ¤·¤¿
162 ¥Û¥¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Î¿ôÃͤËÊÑ´¹¤¹¤ë¡£
163 À®¸ù¤¹¤ë¤È¡¢ÊÑ´¹¤µ¤ì¤¿¥¢¥É¥ì¥¹¤òÊÖ¤¹¡£
164 ÆþÎϤ¬ÉÔÀµ¤Ê¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
165 .PP
166 .BR inet_ntoa ()
167 ´Ø¿ô¤Ï¡¢¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤ÇÅϤµ¤ì¤¿¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¥¢¥É¥ì¥¹
168 \fIin\fP ¤ò¡¢ IPv4 ¤Î¥É¥Ã¥È¶èÀÚ¤ê¤Î 10 ¿Ê¿ôɽµ­¤Îʸ»úÎó¤ËÊÑ´¹¤¹¤ë¡£
169 ʸ»úÎó¤ÏÀÅŪ¤Ë³äÅö¤Æ¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ÆÊÖ¤µ¤ì¤ë¤Î¤Ç¡¢
170 ¤³¤Î¸å¤Ç¤³¤Î´Ø¿ô¤òºÆÅٸƤӽФ¹¤Èʸ»úÎó¤Ï¾å½ñ¤­¤µ¤ì¤ë¡£
171 .PP
172 .BR inet_lnaof ()
173 ´Ø¿ô¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹ \fIin\fP ¤Î¥í¡¼¥«¥ë¥Í¥Ã¥È¥ï¡¼¥¯Éôʬ¤òÊÖ¤¹¡£
174 ¤³¤ÎÊÖ¤êÃͤϥۥ¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤¢¤ë¡£
175 .PP
176 .BR inet_netof ()
177 ´Ø¿ô¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹ \fIin\fP ¤Î¥Í¥Ã¥È¥ï¡¼¥¯Éôʬ¤òÊÖ¤¹¡£
178 ¤³¤ÎÊÖ¤êÃͤϥۥ¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤¢¤ë¡£
179 .PP
180 .BR inet_makeaddr ()
181 ´Ø¿ô¤Ï
182 .BR inet_netof ()
183 ¤È
184 .BR inet_lnaof ()
185 ¤ÎµÕ¤Îµ¡Ç½¤ò»ý¤Ä¡£
186 ¥Í¥Ã¥È¥ï¡¼¥¯ÈÖ¹æ \fInet\fP ¤È¡¢¥í¡¼¥«¥ë¥¢¥É¥ì¥¹ \fIhost\fP ¤ò
187 ÁȤ߹ç¤ï¤»¤ÆÀ¸À®¤·¤¿¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¥¢¥É¥ì¥¹¤ò
188 ¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤ÇÊÖ¤¹¡£
189 \fIhost\fP, \fInet\fP ¤Ï¤È¤â¤Ë¥Û¥¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤¢¤ë¡£
190 .PP
191 .BR inet_ntoa (),
192 .BR inet_makeaddr (),
193 .BR inet_lnaof (),
194 .BR inet_netof ()
195 ¤Ç»ÈÍѤ¹¤ë¹½Â¤ÂΠ\fIin_addr\fP ¤Ï
196 .I <netinet/in.h>
197 ¤Ç¼¡¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
198 .sp
199 .in +4n
200 .nf
201 typedef uint32_t in_addr_t;
202
203 struct in_addr {
204     in_addr_t s_addr;
205 };
206 .fi
207 .in
208 .SH ½àµò
209 4.3BSD.
210 .BR inet_addr (),
211 .BR inet_ntoa ()
212 ¤Ï POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
213 .BR inet_aton ()
214 ¤Ï POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
215 .SH Ãí°Õ
216 i386 ¤Ç¤Ï¥Û¥¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ï Least Significant Byte (LSB) first
217 (¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó) ¤À¤¬¡¢
218 ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¤Ç»È¤ï¤ì¤ë¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Ï
219 Most Significant Byte (MSB) first (¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó)
220 ¤Ç¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
221
222 .BR inet_lnaof (),
223 .BR inet_netof (),
224 .BR inet_makeaddr ()
225 ¤Ï²áµî¤Î̾»Ä¤Ç¤¢¤ê¡¢ÅϤµ¤ì¤¿¥¢¥É¥ì¥¹¤¬
226 .I "¥¯¥é¥¹¥Õ¥ë¡¦¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹ (classful network addresses)"
227 ¤Ç¤¢¤ë¤È²¾Äꤷ¤Æ½èÍý¤ò¹Ô¤¦¡£
228 ¥¯¥é¥¹¥Õ¥ë¡¦¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤Ç¤Ï¡¢°Ê²¼¤Ë¤¢¤ë¤è¤¦¤Ë¡¢
229 IPv4 ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤ò¥Ð¥¤¥È¶­³¦¤Ç¥Í¥Ã¥È¥ï¡¼¥¯Éô¤È¥Û¥¹¥ÈÉô¤Ëʬ³ä¤¹¤ë¡£
230 .TP 10
231 Class A
232 (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥¢¥É¥ì¥¹¤ÎºÇ¾å°Ì¥Ó¥Ã¥È¤¬ 0 ¤Î¾ì¹ç¡¢
233 ¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ȥʤ롣¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ǥϡ¢
234 ºÇ¾å°Ì¥Ð¥¤¥È¤¬¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤òɽ¤·¡¢
235 »Ä¤ê¤Î 3 ¥Ð¥¤¥È¤¬¥Û¥¹¥È¥¢¥É¥ì¥¹¤òɽ¤¹¡£
236 .TP
237 Class B
238 (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥¢¥É¥ì¥¹¤Î¾å°Ì¦ 2 ¥Ó¥Ã¥È¤¬¥Ð¥¤¥Ê¥êÃͤÇ
239 10 ¤Î¾ì¹ç¡¢¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ȥʤ롣¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ǥϡ¢
240 ¾å°Ì 2 ¥Ð¥¤¥È¤¬¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤òɽ¤·¡¢
241 »Ä¤ê¤Î 2 ¥Ð¥¤¥È¤¬¥Û¥¹¥È¥¢¥É¥ì¥¹¤òɽ¤¹¡£
242 .TP
243 Class C
244 (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥¢¥É¥ì¥¹¤Î¾å°Ì¦ 3 ¥Ó¥Ã¥È¤¬¥Ð¥¤¥Ê¥êÃͤÇ
245 110 ¤Î¾ì¹ç¡¢¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ȥʤ롣¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ǥϡ¢
246 ¾å°Ì 3 ¥Ð¥¤¥È¤¬¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤òɽ¤·¡¢
247 »Ä¤ê¤Î 1 ¥Ð¥¤¥È¤¬¥Û¥¹¥È¥¢¥É¥ì¥¹¤òɽ¤¹¡£
248 .PP
249 ¥¯¥é¥¹¥Õ¥ë¡¦¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤Ï¸½ºß¤Ç¤ÏÇѻߤµ¤ì¡¢
250 ¥¯¥é¥¹¥ì¥¹¡¦¥É¥á¥¤¥ó´Ö¥ë¡¼¥Á¥ó (CIDR) ¤Ë¼è¤Ã¤ÆÂå¤ï¤é¤ì¤¿¡£
251 CIDR ¤Ç¤Ï¡¢¥¢¥É¥ì¥¹¤òǤ°Õ¤Î¥Ó¥Ã¥È¶­³¦ (¥Ð¥¤¥È¶­³¦¤Ç¤Ï¤Ê¤¤) ¤Ç
252 ¥Í¥Ã¥È¥ï¡¼¥¯Éô¤È¥Û¥¹¥ÈÉô¤Ëʬ³ä¤¹¤ë¡£
253 .SH Îã
254 °Ê²¼¤Ï
255 .BR inet_aton ()
256 ¤È
257 .BR inet_ntoa ()
258 ¤Î»ÈÍÑÎã¤Ç¤¢¤ë¡£¤³¤Î¤è¤¦¤Ë¼Â¹Ô¤¹¤ë¡£
259 .in +4n
260 .nf
261
262 .RB "$" " ./a.out 226.000.000.037" "      # Last byte is in octal"
263 226.0.0.31
264 .RB "$" " ./a.out 0x7f.1         " "      # First byte is in hex"
265 127.0.0.1
266 .fi
267 .in
268 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
269 \&
270 .nf
271 #define _BSD_SOURCE
272 #include <arpa/inet.h>
273 #include <stdio.h>
274 #include <stdlib.h>
275
276 int
277 main(int argc, char *argv[])
278 {
279     struct in_addr addr;
280
281     if (argc != 2) {
282         fprintf(stderr, "%s <dotted\-address>\\n", argv[0]);
283         exit(EXIT_FAILURE);
284     }
285
286     if (inet_aton(argv[1], &addr) == 0) {
287         perror("inet_aton");
288         exit(EXIT_FAILURE);
289     }
290
291     printf("%s\\n", inet_ntoa(addr));
292     exit(EXIT_SUCCESS);
293 }
294 .fi
295 .SH ´ØÏ¢¹àÌÜ
296 .BR byteorder (3),
297 .BR getaddrinfo (3),
298 .BR gethostbyname (3),
299 .BR getnameinfo (3),
300 .BR getnetent (3),
301 .BR inet_ntop (3),
302 .BR inet_pton (3),
303 .BR hosts (5),
304 .BR networks (5)