.\" 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 2013\-06\-21 "" "Linux Programmer's Manual" .SH 名前 bindresvport \- ソケットを特権 IP ポートにバインドする .SH 書式 .nf \fB#include \fP \fB#include \fP .LP \fBint bindresvport(int \fP\fIsockfd\fP\fB, struct sockaddr_in *\fP\fIsin\fP\fB);\fP .fi .SH 説明 .LP .\" Glibc actually starts searching with a port # in the range 600 to 1023 \fBbindresvport\fP() は、ソケット・ディスクリプタを特権無名 (privileged anonymous) IP ポートに バインドするのに使う。特権無名 IP ポートとは、 ポート番号が 512 から 1023 の範囲から任意に選択されるポートである。 \fBbindresvport\fP() によって実行された \fBbind\fP(2) が成功し、 \fIsin\fP が NULL 以外の場合、実際に割り当てられたポート番号が \fIsin\->sin_port\fP に入れて返される。 \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 呼び出し元がスーパーユーザの特権を持っていなかった (より正確に言うと、 \fBCAP_NET_BIND_SERVICE\fP ケーパビリティが必要である)。 .TP \fBEADDRINUSE\fP 全ての特権ポートが使用中である。 .TP \fBEAFNOSUPPORT\fP (glibc 2.7 以前では \fBEPFNOSUPPORT\fP) \fIsin\fP が NULL 以外で、かつ \fIsin\->sin_family\fP が \fBAF_INET\fP でなかった。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" glibc 2.17 より前のバージョンでは、 \fBbindresvport\fP() 関数は保護されていない静的変数を使用しているため、スレッドセーフではない。 .\" commit f6da27e53695ad1cc0e2a9490358decbbfdff5e5 glibc 2.17 以降では、 \fBbindresvport\fP() 関数は静的変数を保護するロックを使っており、スレッドセーフである。 .SH 準拠 POSIX.1\-2001 にはない。 BSD, Solaris およびその他の多くのシステムに存在する。 .SH 注意 \fBbindresvport\fP() のいくつかの実装と異なり、glibc の実装では呼び出し元が \fIsin\->sin_port\fP で渡した値はどんな値であっても無視される。 .SH 関連項目 \fBbind\fP(2), \fBgetsockname\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。