.\" Copyright (C) 2007, Michael Kerrisk .\" and Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk .\" .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" 2007-05-31, mtk: Rewrite and substantial additional text. .\" 2008-12-03, mtk: Rewrote some pieces and fixed some errors .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1999 Shouichi Saito all rights reserved. .\" Translated 1999-08-28, Shouichi Saito .\" Proofed 1999-09-25, NAKANO Takeo .\" Updated 2007-06-11, Akihiro MOTOKI , LDP v2.54 .\" Updated 2008-12-24, Akihiro MOTOKI , LDP v3.15 .\" Updated 2013-07-24, Akihiro MOTOKI .\" .TH BINDRESVPORT 3 2017\-09\-15 "" "Linux Programmer's Manual" .SH 名前 bindresvport \- ソケットを特権 IP ポートにバインドする .SH 書式 .nf \fB#include \fP \fB#include \fP .PP \fBint bindresvport(int \fP\fIsockfd\fP\fB, struct sockaddr_in *\fP\fIsin\fP\fB);\fP .fi .SH 説明 .\" Glibc actually starts searching with a port # in the range 600 to 1023 \fBbindresvport\fP() is used to bind the socket referred to by the file descriptor \fIsockfd\fP to a privileged anonymous IP port, that is, a port number arbitrarily selected from the range 512 to 1023. .PP \fBbindresvport\fP() によって実行された \fBbind\fP(2) が成功し、 \fIsin\fP が NULL 以外の場合、実際に割り当てられたポート番号が \fIsin\->sin_port\fP に入れて返される。 .PP \fIsin\fP には NULL を指定することもでき、その場合には \fIsin\->sin_family\fP は暗黙のうちに \fBAF_INET\fP とみなされる。 しかし、この場合には、 \fBbindresvport\fP() は実際に割り当てられたポート番号を返す手段を持たない (割り当てられたポート番号は、後で \fBgetsockname\fP(2) を使って取得できる)。 .SH 返り値 \fBbindresvport\fP() は成功すると 0 を返す。それ以外の場合、\-1 を返し、 \fIerrno\fP にエラーの原因を示す値を設定する。 .SH エラー \fBbindresvport\fP() は \fBbind\fP(2) と同じ原因で失敗する可能性がある。 さらに、以下のエラーが発生することがある: .TP \fBEACCES\fP The calling process was not privileged (on Linux: the calling process did not have the \fBCAP_NET_BIND_SERVICE\fP capability in the user namespace governing its network namespace). .TP \fBEADDRINUSE\fP 全ての特権ポートが使用中である。 .TP \fBEAFNOSUPPORT\fP (glibc 2.7 以前では \fBEPFNOSUPPORT\fP) \fIsin\fP が NULL 以外で、かつ \fIsin\->sin_family\fP が \fBAF_INET\fP でなかった。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l lw23. インターフェース 属性 値 T{ \fBbindresvport\fP() T} Thread safety T{ .\" commit f6da27e53695ad1cc0e2a9490358decbbfdff5e5 glibc >= 2.17: MT\-Safe .br glibc < 2.17: MT\-Unsafe T} .TE .PP The \fBbindresvport\fP() function uses a static variable that was not protected by a lock before glibc 2.17, rendering the function MT\-Unsafe. .SH 準拠 Not in POSIX.1. Present on the BSDs, Solaris, and many other systems. .SH 注意 \fBbindresvport\fP() のいくつかの実装と異なり、glibc の実装では呼び出し元が \fIsin\->sin_port\fP で渡した値はどんな値であっても無視される。 .SH 関連項目 \fBbind\fP(2), \fBgetsockname\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。