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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" 2007-05-31, mtk: Rewrite and substantial additional text.
25 .\" 2008-12-03, mtk: Rewrote some pieces and fixed some errors
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
33 .TH BINDRESVPORT 3 2008-12-03 "" "Linux Programmer's Manual"
36 .\"O bindresvport \- bind a socket to a privileged IP port
37 bindresvport \- ¥½¥±¥Ã¥È¤òÆø¢ IP ¥Ý¡¼¥È¤Ë¥Ð¥¤¥ó¥É¤¹¤ë
41 .B #include <sys/types.h>
42 .B #include <netinet/in.h>
44 .BI "int bindresvport(int " sockfd ", struct sockaddr_in *" sin );
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.
53 ¤Ï¡¢¥½¥±¥Ã¥È¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÆø¢ÌµÌ¾ (privileged anonymous) IP ¥Ý¡¼¥È¤Ë
54 ¥Ð¥¤¥ó¥É¤¹¤ë¤Î¤Ë»È¤¦¡£Æø¢ÌµÌ¾ IP ¥Ý¡¼¥È¤È¤Ï¡¢
55 ¥Ý¡¼¥ÈÈֹ椬 512 ¤«¤é 1023 ¤ÎÈϰϤ«¤éǤ°Õ¤ËÁªÂò¤µ¤ì¤ë¥Ý¡¼¥È¤Ç¤¢¤ë¡£
56 .\" Glibc actually starts searching with a port # in the range 600 to 1023
61 .\"O .BR bindresvport ()
62 .\"O is successful, and
64 .\"O is not NULL, then
65 .\"O .I sin\->sin_port
66 .\"O returns the port number actually allocated.
72 ¤¬ NULL °Ê³°¤Î¾ì¹ç¡¢¼ÂºÝ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿¥Ý¡¼¥ÈÈֹ椬
77 .\"O can be NULL, in which case
78 .\"O .I sin\->sin_family
79 .\"O is implicitly taken to be
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).)
87 ¤Ë¤Ï NULL ¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤¡¢¤½¤Î¾ì¹ç¤Ë¤Ï
92 ¤·¤«¤·¡¢¤³¤Î¾ì¹ç¤Ë¤Ï¡¢
94 ¤Ï¼ÂºÝ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿¥Ý¡¼¥ÈÈÖ¹æ¤òÊÖ¤¹¼êÃʤò»ý¤¿¤Ê¤¤
95 (³ä¤êÅö¤Æ¤é¤ì¤¿¥Ý¡¼¥ÈÈÖ¹æ¤Ï¡¢¸å¤Ç
100 .\"O .BR bindresvport ()
101 .\"O returns 0 on success; otherwise \-1 is returned and
103 .\"O set to indicate the cause of the error.
105 ¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
107 ¤Ë¥¨¥é¡¼¤Î¸¶°ø¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
110 .\"O .BR bindresvport ()
111 .\"O can fail for any of the same reasons as
116 ¤ÈƱ¤¸¸¶°ø¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
117 .\"O In addition, the following errors may occur:
118 ¤µ¤é¤Ë¡¢°Ê²¼¤Î¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤³¤È¤¬¤¢¤ë:
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 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤¬É¬ÍפǤ¢¤ë)¡£
129 .\"O All privileged ports are in use.
130 Á´¤Æ¤ÎÆø¢¥Ý¡¼¥È¤¬»ÈÍÑÃæ¤Ç¤¢¤ë¡£
132 .\"O .BR EAFNOSUPPORT " (" EPFNOSUPPORT " in glibc 2.7 and earlier)"
133 .BR EAFNOSUPPORT " (glibc 2.7 °ÊÁ°¤Ç¤Ï " EPFNOSUPPORT ")"
136 .\"O .I sin->sin_family
145 .\"O .SH "CONFORMING TO"
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 ¤ª¤è¤Ó¤½¤Î¾¤Î¿¤¯¤Î¥·¥¹¥Æ¥à¤Ë¸ºß¤¹¤ë¡£
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 .
160 ¤Î¤¤¤¯¤Ä¤«¤Î¼ÂÁõ¤È°Û¤Ê¤ê¡¢glibc ¤Î¼ÂÁõ¤Ç¤Ï¸Æ¤Ó½Ð¤·¸µ¤¬
162 ¤ÇÅϤ·¤¿ÃͤϤɤó¤ÊÃͤǤ¢¤Ã¤Æ¤â̵»ë¤µ¤ì¤ë¡£