plucky (3) bindresvport.3.gz

Provided by: manpages-ja-dev_0.5.0.0.20221215+dfsg-1_all bug

名前

       bindresvport - ソケットを特権 IP ポートにバインドする

書式

       #include <sys/types.h>
       #include <netinet/in.h>

       int bindresvport(int sockfd, struct sockaddr_in *sin);

説明

       bindresvport()   is  used  to  bind  the socket referred to by the file descriptor sockfd to a privileged
       anonymous IP port, that is, a port number arbitrarily selected from the range 512 to 1023.

       bindresvport()  によって実行された bind(2)  が成功し、 sin が NULL 以外の場合、実際に割り当てられたポート
       番号が sin->sin_port に入れて返される。

       sin には NULL を指定することもでき、その場合には sin->sin_family は暗黙のうちに AF_INET とみなされる。 し
       かし、この場合には、 bindresvport()  は実際に割り当てられたポート番号を返す手段を持たない (割り当てられた
       ポート番号は、後で getsockname(2)  を使って取得できる)。

返り値

       bindresvport()   は成功すると  0 を返す。それ以外の場合、-1 を返し、 errno にエラーの原因を示す値を設定す
       る。

エラー

       bindresvport()  は bind(2)  と同じ原因で失敗する可能性がある。 さらに、以下のエラーが発生することがある:

       EACCES The calling process  was  not  privileged  (on  Linux:  the  calling  process  did  not  have  the
              CAP_NET_BIND_SERVICE capability in the user namespace governing its network namespace).

       EADDRINUSE
              全ての特権ポートが使用中である。

       EAFNOSUPPORT (glibc 2.7 以前では EPFNOSUPPORT)
              sin が NULL 以外で、かつ sin->sin_familyAF_INET でなかった。

属性

       この節で使用されている用語の説明については、 attributes(7) を参照。

       ┌─────────────────┬───────────────┬─────────────────────────┐
       │インターフェース属性                      │
       ├─────────────────┼───────────────┼─────────────────────────┤
       │bindresvport()   │ Thread safety │ glibc >= 2.17: MT-Safe  │
       │                 │               │ glibc < 2.17: MT-Unsafe │
       └─────────────────┴───────────────┴─────────────────────────┘
       The  bindresvport()   function uses a static variable that was not protected by a lock before glibc 2.17,
       rendering the function MT-Unsafe.

準拠

       Not in POSIX.1.  Present on the BSDs, Solaris, and many other systems.

注意

       bindresvport()  のいくつかの実装と異なり、glibc の実装では呼び出し元が sin->sin_port で渡した値はどんな値
       であっても無視される。

関連項目

       bind(2), getsockname(2)

この文書について

       この  man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告
       に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

                                                   2017-09-15                                    BINDRESVPORT(3)