OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[linuxjm/LDP_man-pages.git] / draft / man3 / bindresvport.3
1 .\" Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" and Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" 2007-05-31, mtk: Rewrite and substantial additional text.
25 .\" 2008-12-03, mtk: Rewrote some pieces and fixed some errors
26 .\"
27 .\" Japanese Version Copyright (c) 1999 Shouichi Saito all rights reserved.
28 .\" Translated 1999-08-28, Shouichi Saito <ss236rx@ymg.urban.ne.jp>
29 .\" Proofed 1999-09-25, NAKANO Takeo <nakano@apm.seikei.ac.jp>
30 .\" Updated 2007-06-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.54
31 .\" Updated 2008-12-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.15
32 .\"
33 .TH BINDRESVPORT 3  2008-12-03 "" "Linux Programmer's Manual"
34 .\"O .SH NAME
35 .SH Ì¾Á°
36 .\"O bindresvport \- bind a socket to a privileged IP port
37 bindresvport \- ¥½¥±¥Ã¥È¤òÆø¢ IP ¥Ý¡¼¥È¤Ë¥Ð¥¤¥ó¥É¤¹¤ë
38 .\"O .SH SYNOPSIS
39 .SH ½ñ¼°
40 .nf
41 .B #include <sys/types.h>
42 .B #include <netinet/in.h>
43 .LP
44 .BI "int bindresvport(int " sockfd ", struct sockaddr_in *" sin );
45 .fi
46 .\"O .SH DESCRIPTION
47 .SH ÀâÌÀ
48 .LP
49 .\"O .BR bindresvport ()
50 .\"O is used to bind a socket descriptor to a privileged anonymous IP port,
51 .\"O that is, a port number arbitrarily selected from the range 512 to 1023.
52 .BR bindresvport ()
53 ¤Ï¡¢¥½¥±¥Ã¥È¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÆø¢ÌµÌ¾ (privileged anonymous) IP ¥Ý¡¼¥È¤Ë
54 ¥Ð¥¤¥ó¥É¤¹¤ë¤Î¤Ë»È¤¦¡£Æø¢ÌµÌ¾ IP ¥Ý¡¼¥È¤È¤Ï¡¢
55 ¥Ý¡¼¥ÈÈֹ椬 512 ¤«¤é 1023 ¤ÎÈϰϤ«¤éǤ°Õ¤ËÁªÂò¤µ¤ì¤ë¥Ý¡¼¥È¤Ç¤¢¤ë¡£
56 .\" Glibc actually starts searching with a port # in the range 600 to 1023
57
58 .\"O If the
59 .\"O .BR bind (2)
60 .\"O performed by
61 .\"O .BR bindresvport ()
62 .\"O is successful, and
63 .\"O .I sin
64 .\"O is not NULL, then
65 .\"O .I sin\->sin_port
66 .\"O returns the port number actually allocated.
67 .BR bindresvport ()
68 ¤Ë¤è¤Ã¤Æ¼Â¹Ô¤µ¤ì¤¿
69 .BR bind (2)
70 ¤¬À®¸ù¤·¡¢
71 .I sin
72 ¤¬ NULL °Ê³°¤Î¾ì¹ç¡¢¼ÂºÝ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿¥Ý¡¼¥ÈÈֹ椬
73 .I sin\->sin_port
74 ¤ËÆþ¤ì¤ÆÊÖ¤µ¤ì¤ë¡£
75
76 .\"O .I sin
77 .\"O can be NULL, in which case
78 .\"O .I sin\->sin_family
79 .\"O is implicitly taken to be
80 .\"O .BR AF_INET .
81 .\"O However, in this case,
82 .\"O .BR bindresvport ()
83 .\"O has no way to return the port number actually allocated.
84 .\"O (This information can later be obtained using
85 .\"O .BR getsockname (2).)
86 .I sin
87 ¤Ë¤Ï NULL ¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤­¡¢¤½¤Î¾ì¹ç¤Ë¤Ï
88 .I sin\->sin_family
89 ¤Ï°ÅÌۤΤ¦¤Á¤Ë
90 .B AF_INET
91 ¤È¤ß¤Ê¤µ¤ì¤ë¡£
92 ¤·¤«¤·¡¢¤³¤Î¾ì¹ç¤Ë¤Ï¡¢
93 .BR bindresvport ()
94 ¤Ï¼ÂºÝ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿¥Ý¡¼¥ÈÈÖ¹æ¤òÊÖ¤¹¼êÃʤò»ý¤¿¤Ê¤¤
95 (³ä¤êÅö¤Æ¤é¤ì¤¿¥Ý¡¼¥ÈÈÖ¹æ¤Ï¡¢¸å¤Ç
96 .BR getsockname (2)
97 ¤ò»È¤Ã¤Æ¼èÆÀ¤Ç¤­¤ë)¡£
98 .\"O .SH RETURN VALUE
99 .SH ÊÖ¤êÃÍ
100 .\"O .BR bindresvport ()
101 .\"O returns 0 on success; otherwise \-1 is returned and
102 .\"O .I errno
103 .\"O set to indicate the cause of the error.
104 .BR bindresvport ()
105 ¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
106 .I errno
107 ¤Ë¥¨¥é¡¼¤Î¸¶°ø¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
108 .\"O .SH ERRORS
109 .SH ¥¨¥é¡¼
110 .\"O .BR bindresvport ()
111 .\"O can fail for any of the same reasons as
112 .\"O .BR bind (2).
113 .BR bindresvport ()
114 ¤Ï
115 .BR bind (2)
116 ¤ÈƱ¤¸¸¶°ø¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
117 .\"O In addition, the following errors may occur:
118 ¤µ¤é¤Ë¡¢°Ê²¼¤Î¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤³¤È¤¬¤¢¤ë:
119 .TP
120 .BR EACCES
121 .\"O The caller did not have superuser privilege (to be precise: the
122 .\"O .B CAP_NET_BIND_SERVICE
123 .\"O capability is required).
124 ¸Æ¤Ó½Ð¤·¸µ¤¬¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤ÎÆø¢¤ò»ý¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿ (¤è¤êÀµ³Î¤Ë¸À¤¦¤È¡¢
125 .B CAP_NET_BIND_SERVICE
126 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤¬É¬ÍפǤ¢¤ë)¡£
127 .TP
128 .B EADDRINUSE
129 .\"O All privileged ports are in use.
130 Á´¤Æ¤ÎÆø¢¥Ý¡¼¥È¤¬»ÈÍÑÃæ¤Ç¤¢¤ë¡£
131 .TP
132 .\"O .BR EAFNOSUPPORT " (" EPFNOSUPPORT " in glibc 2.7 and earlier)"
133 .BR EAFNOSUPPORT " (glibc 2.7 °ÊÁ°¤Ç¤Ï " EPFNOSUPPORT ")"
134 .\"O .I sin
135 .\"O is not NULL and
136 .\"O .I sin->sin_family
137 .\"O is not
138 .\"O .BR AF_INET .
139 .I sin
140 ¤¬ NULL °Ê³°¤Ç¡¢¤«¤Ä
141 .I sin->sin_family
142 ¤¬
143 .B AF_INET
144 ¤Ç¤Ê¤«¤Ã¤¿¡£
145 .\"O .SH "CONFORMING TO"
146 .SH ½àµò
147 .\"O Not in POSIX.1-2001.
148 .\"O Present on the BSDs, Solaris, and many other systems.
149 POSIX.1-2001 ¤Ë¤Ï¤Ê¤¤¡£
150 BSD, Solaris ¤ª¤è¤Ó¤½¤Î¾¤Î¿¤¯¤Î¥·¥¹¥Æ¥à¤Ë¸ºß¤¹¤ë¡£
151 .\"O .SH NOTES
152 .SH Ãí°Õ
153 .LP
154 .\"O Unlike some
155 .\"O .BR bindresvport ()
156 .\"O implementations,
157 .\"O the glibc implementation ignores any value that the caller supplies in
158 .\"O .IR sin\->sin_port .
159 .BR bindresvport ()
160 ¤Î¤¤¤¯¤Ä¤«¤Î¼ÂÁõ¤È°Û¤Ê¤ê¡¢glibc ¤Î¼ÂÁõ¤Ç¤Ï¸Æ¤Ó½Ð¤·¸µ¤¬
161 .I sin\->sin_port
162 ¤ÇÅϤ·¤¿ÃͤϤɤó¤ÊÃͤǤ¢¤Ã¤Æ¤â̵»ë¤µ¤ì¤ë¡£
163 .\"O .SH SEE ALSO
164 .SH ´ØÏ¢¹àÌÜ
165 .BR bind (2),
166 .BR getsockname (2)