-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\" Portions extracted from /usr/include/sys/socket.h, which does not have
.\" any authorship information in it. It is probably available under the GPL.
.\"
+.\" %%%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.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\"
.\" Other portions are from the 6.9 (Berkeley) 3/10/91 man page:
.\" Copyright (c) 1983 The Regents of the University of California.
.\" All rights reserved.
.\"
+.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
+.\" %%%LICENSE_END
.\"
.\" Modified Mon Oct 21 23:05:29 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 1998 by Andi Kleen
.\" $Id: bind.2,v 1.3 1999/04/23 19:56:07 freitag Exp $
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
-.\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
-.\" all rights reserved.
-.\" Translated 1996-06-25, Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
-.\" Modified 1997-11-06, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
-.\" Modified 1999-08-02, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
-.\" Updated 2005-02-03, Yuichi SATO <ysato444@yahoo.co.jp>
-.\" Updated 2005-12-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
-.\" Updated 2006-07-19, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
-.\" Updated 2007-06-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.55
-.\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
.\"
-.TH BIND 2 2007-12-28 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
+.\"*******************************************************************
+.TH BIND 2 2007\-12\-28 Linux "Linux Programmer's Manual"
.SH 名前
-.\"O bind \- bind a name to a socket
bind \- ソケットに名前をつける
-.\"O .SH SYNOPSIS
.SH 書式
.nf
-.\"O .BR "#include <sys/types.h>" " /* See NOTES */"
-.BR "#include <sys/types.h>" " /* 「注意」参照 */"
-.B #include <sys/socket.h>
+\fB#include <sys/types.h>\fP /* 「注意」参照 */
+\fB#include <sys/socket.h>\fP
.sp
-.BI "int bind(int " sockfd ", const struct sockaddr *" addr ,
-.BI " socklen_t " addrlen );
+\fBint bind(int \fP\fIsockfd\fP\fB, const struct sockaddr *\fP\fIaddr\fP\fB,\fP
+\fB socklen_t \fP\fIaddrlen\fP\fB);\fP
.fi
-.\"O .SH DESCRIPTION
.SH 説明
-.\"O When a socket is created with
-.\"O .BR socket (2),
-.\"O it exists in a name space (address family) but has no address assigned to it.
-.\"O .BR bind ()
-.\"O assigns the address specified to by
-.\"O .I addr
-.\"O to the socket referred to by the file descriptor
-.\"O .IR sockfd .
-.\"O .I addrlen
-.\"O specifies the size, in bytes, of the address structure pointed to by
-.\"O .IR addr .
-.\"O Traditionally, this operation is called \(lqassigning a name to a socket\(rq.
-.BR socket (2)
-でソケットが作成されたとき、そのソケットは名前空間 (アドレス・ファミリー) に
-存在するが、アドレスは割り当てられていない。
-.BR bind ()
-は、ファイルディスクリプタ
-.I sockfd
-で参照されるソケットに
-.I addr
-で指定されたアドレスを割り当てる。
-.I addrlen
-には
-.I addr
-が指すアドレス構造体のサイズをバイト単位で指定する。
-伝統的にこの操作は
-「ソケットに名前をつける」
-と呼ばれる。
+\fBsocket\fP(2) でソケットが作成されたとき、そのソケットは名前空間 (アドレス・ファミリー) に
+存在するが、アドレスは割り当てられていない。 \fBbind\fP() は、ファイルディスクリプタ \fIsockfd\fP で参照されるソケットに
+\fIaddr\fP で指定されたアドレスを割り当てる。 \fIaddrlen\fP には \fIaddr\fP が指すアドレス構造体のサイズをバイト単位で指定する。
+伝統的にこの操作は 「ソケットに名前をつける」 と呼ばれる。
.PP
-.\"O It is normally necessary to assign a local address using
-.\"O .BR bind ()
-.\"O before a
-.\"O .B SOCK_STREAM
-.\"O socket may receive connections (see
-.\"O .BR accept (2)).
-.B SOCK_STREAM
-ソケットが接続を受け付けられるようにするには
-.RB ( accept (2)
-を参照)、通常その前に
-.BR bind ()
+\fBSOCK_STREAM\fP ソケットが接続を受け付けられるようにするには (\fBaccept\fP(2) を参照)、通常その前に \fBbind\fP()
を使用してローカルアドレスを割り当てる必要がある。
-.\"O The rules used in name binding vary between address families.
-.\"O Consult the manual entries in Section 7 for detailed information.
-.\"O For
-.\"O .B AF_INET
-.\"O see
-.\"O .BR ip (7),
-名前付けのルールはアドレス・ファミリーごとに異なっている。詳細な情報は
-第 7 章の各マニュアルを参照すること。
-.B AF_INET
-は
-.BR ip (7)
-を、
-.\"O for
-.\"O .B AF_INET6
-.\"O see
-.\"O .BR ipv6 (7),
-.B AF_INET6
-は
-.BR ipv6 (7)
-を、
-.\"O for
-.\"O .B AF_UNIX
-.\"O see
-.\"O .BR unix (7),
-.B AF_UNIX
-は
-.BR unix (7)
-を、
-.\"O for
-.\"O .B AF_APPLETALK
-.\"O see
-.\"O .BR ddp (7),
-.B AF_APPLETALK
-は
-.BR ddp (7)
-を、
-.\"O for
-.\"O .B AF_PACKET
-.\"O see
-.\"O .BR packet (7),
-.B AF_PACKET
-は
-.BR packet (7)
-を、
-.\"O for
-.\"O .B AF_X25
-.\"O see
-.\"O .BR x25 (7)
-.B AF_X25
-は
-.BR x25 (7)
-を、
-.\"O and for
-.\"O .B AF_NETLINK
-.\"O see
-.\"O .BR netlink (7).
-.B AF_NETLINK
-は
-.BR netlink (7)
-を参照。
+名前付けのルールはアドレス・ファミリーごとに異なっている。詳細な情報は 第 7 章の各マニュアルを参照すること。 \fBAF_INET\fP は
+\fBip\fP(7) を、 \fBAF_INET6\fP は \fBipv6\fP(7) を、 \fBAF_UNIX\fP は \fBunix\fP(7) を、
+\fBAF_APPLETALK\fP は \fBddp\fP(7) を、 \fBAF_PACKET\fP は \fBpacket\fP(7) を、 \fBAF_X25\fP は
+\fBx25\fP(7) を、 \fBAF_NETLINK\fP は \fBnetlink\fP(7) を参照。
-.\"O The actual structure passed for the
-.\"O .I addr
-.\"O argument will depend on the address family.
-.\"O The
-.\"O .I sockaddr
-.\"O structure is defined as something like:
-.I addr
-引き数に実際にどのような構造体が渡されるかは、
-アドレス・ファミリーに依存する。
-.I sockaddr
+\fIaddr\fP 引き数に実際にどのような構造体が渡されるかは、 アドレス・ファミリーに依存する。 \fIsockaddr\fP
構造体は以下のような感じで定義されている:
.in +4n
.nf
.fi
.in
-.\"O The only purpose of this structure is to cast the structure
-.\"O pointer passed in
-.\"O .I addr
-.\"O in order to avoid compiler warnings.
-.\"O See EXAMPLE below.
-この構造体は、
-.I addr
-に渡される構造体へのポインタをキャストし、
-コンパイラの警告メッセージを抑えるためだけに存在する。
-下記の「例」を参照。
-.\"O .SH "RETURN VALUE"
+この構造体は、 \fIaddr\fP に渡される構造体へのポインタをキャストし、 コンパイラの警告メッセージを抑えるためだけに存在する。 下記の「例」を参照。
.SH 返り値
-.\"O On success, zero is returned.
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-成功すると 0 を返す。
-失敗すると \-1 を返し、
-.I errno
-を適切に設定する。
-.\"O .SH ERRORS
+成功した場合にはゼロが返される。エラー時には \-1 が返され、 \fIerrno\fP が適切に設定される。
.SH エラー
-.TP
-.B EACCES
+.TP
+\fBEACCES\fP
.\" e.g., privileged port in AF_INET domain
-.\"O The address is protected, and the user is not the superuser.
そのアドレスは保護されていて、かつユーザがスーパーユーザではない。
-.TP
-.B EADDRINUSE
-.\"O The given address is already in use.
+.TP
+\fBEADDRINUSE\fP
指定されたアドレスが既に使用中である。
-.TP
-.B EBADF
-.\"O .I sockfd
-.\"O is not a valid descriptor.
-.I sockfd
-が不正なディスクリプタである。
-.TP
-.B EINVAL
-.\"O The socket is already bound to an address.
-.\"O .\" This may change in the future: see
-.\"O .\" .I linux/unix/sock.c for details.
+.TP
+\fBEBADF\fP
+\fIsockfd\fP が不正なディスクリプタである。
+.TP
+\fBEINVAL\fP
+.\" This may change in the future: see
+.\" .I linux/unix/sock.c for details.
ソケットがすでにアドレスに結びつけ (bind) られている。
-.\" これは将来変更されるかもしれない。
-.\" 詳しくは
-.\" .I linux/unix/sock.c
-.\" を参照すること。
-.B ENOTSOCK
-.\"O .I sockfd
-.\"O is a descriptor for a file, not a socket.
-.I sockfd
-がファイルに対するディスクリプタで、ソケットに対するものではない。
+.TP
+\fBENOTSOCK\fP
+\fIsockfd\fP がファイルに対するディスクリプタで、ソケットに対するものではない。
.PP
-.\"O The following errors are specific to UNIX domain
-.\"O .RB ( AF_UNIX )
-.\"O sockets:
-以下のエラーは UNIXドメイン
-.RB ( AF_UNIX )
-のソケット特有である:
-.TP
-.B EACCES
-.\"O Search permission is denied on a component of the path prefix.
-.\"O (See also
-.\"O .BR path_resolution (7).)
-パス名の構成要素に検索許可 (search permission) がない
-.RB ( path_resolution (7)
-も参照すること)。
-.TP
-.B EADDRNOTAVAIL
-.\"O A nonexistent interface was requested or the requested
-.\"O address was not local.
-存在しないインタフェースが要求されたか、要求されたアドレスが
-ローカルではなかった。
-.TP
-.B EFAULT
-.\"O .I addr
-.\"O points outside the user's accessible address space.
-.I addr
-がユーザのアクセス可能なアドレス空間の外を指している。
-.TP
-.B EINVAL
-.\"O The
-.\"O .I addrlen
-.\"O is wrong, or the socket was not in the
-.\"O .B AF_UNIX
-.\"O family.
-.I addrlen
-が不正であるか、ソケットが
-.B AF_UNIX
-ファミリーではない。
-.TP
-.B ELOOP
-.\"O Too many symbolic links were encountered in resolving
-.\"O .IR addr .
-.I addr
-を解決する際に遭遇したシンボリック・リンクが多過ぎる。
-.TP
-.B ENAMETOOLONG
-.\"O .I addr
-.\"O is too long.
-.I addr
-が長過ぎる。
-.TP
-.B ENOENT
-.\"O The file does not exist.
+以下のエラーは UNIXドメイン (\fBAF_UNIX\fP) のソケット特有である:
+.TP
+\fBEACCES\fP
+パス名の構成要素に検索許可 (search permission) がない (\fBpath_resolution\fP(7) も参照すること)。
+.TP
+\fBEADDRNOTAVAIL\fP
+存在しないインタフェースが要求されたか、要求されたアドレスが ローカルではなかった。
+.TP
+\fBEFAULT\fP
+\fIaddr\fP がユーザのアクセス可能なアドレス空間の外を指している。
+.TP
+\fBEINVAL\fP
+\fIaddrlen\fP が不正であるか、ソケットが \fBAF_UNIX\fP ファミリーではない。
+.TP
+\fBELOOP\fP
+\fIaddr\fP を解決する際に遭遇したシンボリック・リンクが多過ぎる。
+.TP
+\fBENAMETOOLONG\fP
+\fIaddr\fP が長過ぎる。
+.TP
+\fBENOENT\fP
ファイルが存在しない。
-.TP
-.B ENOMEM
-.\"O Insufficient kernel memory was available.
+.TP
+\fBENOMEM\fP
カーネルに、利用可能なメモリーが十分にない。
-.TP
-.B ENOTDIR
-.\"O A component of the path prefix is not a directory.
+.TP
+\fBENOTDIR\fP
パス名の構成要素がディレクトリではない。
-.TP
-.B EROFS
-.\"O The socket inode would reside on a read-only file system.
+.TP
+\fBEROFS\fP
ソケット inode が読み込み専用のファイルシステム上にある。
-.\"O .SH "CONFORMING TO"
.SH 準拠
-.\"O SVr4, 4.4BSD, POSIX.1-2001
-.\"O .RB ( bind ()
-.\"O first appeared in 4.2BSD).
-.\"O .\" SVr4 documents an additional
-.\"O .\" .B ENOSR
-.\"O .\" general error condition, and
-.\"O .\" additional
-.\"O .\" .B EIO
-.\"O .\" and
-.\"O .\" .B EISDIR
-.\"O .\" UNIX-domain error conditions.
-SVr4, 4.4BSD, POSIX.1-2001
-.RB ( bind ()
-は 4.2BSD で最初に現われた)。
-.\" SVr4 には他に、一般のエラー状態
+.\" SVr4 documents an additional
.\" .B ENOSR
-.\" 及び UNIX ドメインのエラー状態
-.\" .BR EIO ,
+.\" general error condition, and
+.\" additional
+.\" .B EIO
+.\" and
.\" .B EISDIR
-.\" についての記述がある。
-.\"O .SH NOTES
+.\" UNIX-domain error conditions.
+SVr4, 4.4BSD, POSIX.1\-2001 (\fBbind\fP() は 4.2BSD で最初に現われた)。
.SH 注意
-.\"O POSIX.1-2001 does not require the inclusion of
-.\"O .IR <sys/types.h> ,
-.\"O and this header file is not required on Linux.
-.\"O However, some historical (BSD) implementations required this header
-.\"O file, and portable applications are probably wise to include it.
-POSIX.1-2001 では
-.I <sys/types.h>
-のインクルードは必須とされておらず、
-Linux ではこのヘッダファイルは必要ではない。
-しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダファイルが
-必要であり、移植性が必要なアプリケーションではこのファイルを
-インクルードするのが賢明であろう。
+POSIX.1\-2001 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
-.\"O The third argument of
-.\"O .BR bind ()
-.\"O is in reality an
-.\"O .I int
-.\"O (and this is what 4.x BSD and libc4 and libc5 have).
-.\"O Some POSIX confusion resulted in the present
-.\"O .IR socklen_t ,
-.\"O also used by glibc.
-.\"O See also
-.\"O .BR accept (2).
-.BR bind ()
-の三番目の引き数は (4.x BSD や libc4, libc5 と同様に) 実際には
-.I int
-である。glibc でも使われている現在の
-.I socklen_t
-に関して、POSIX には少し混乱がある。
-詳しくは
-.BR accept (2)
-を参照のこと。
-.\"O .SH BUGS
+\fBbind\fP() の三番目の引き数は (4.x BSD や libc4, libc5 と同様に) 実際には \fIint\fP である。glibc
+でも使われている現在の \fIsocklen_t\fP に関して、POSIX には少し混乱がある。 詳しくは \fBaccept\fP(2) を参照のこと。
.SH バグ
-.\"O The transparent proxy options are not described.
-透過的プロキシ (transparent proxy) オプションについて記述していない。
.\" FIXME What *are* transparent proxy options?
-.\"O .SH EXAMPLE
+透過的プロキシ (transparent proxy) オプションについて記述していない。
.SH 例
-.\"O An example of the use of
-.\"O .BR bind ()
-.\"O with Internet domain sockets can be found in
-.\"O .BR getaddrinfo (3).
-インターネット・ドメイン・ソケットでの
-.BR bind ()
-の利用例が
-.BR getaddrinfo (3)
-に記載されている。
+インターネット・ドメイン・ソケットでの \fBbind\fP() の利用例が \fBgetaddrinfo\fP(3) に記載されている。
-.\"O The following example shows how to bind a stream socket in the UNIX
-.\"O .RB ( AF_UNIX )
-.\"O domain, and accept connections:
-以下の例は、UNIX ドメイン
-.RB ( AF_UNIX )
-でストリームソケットを bind する方法を示したものである。
.\" listen.7 refers to this example.
.\" accept.7 refers to this example.
.\" unix.7 refers to this example.
+以下の例は、UNIX ドメイン (\fBAF_UNIX\fP) でストリームソケットを bind する方法を示したものである。
.nf
#include <sys/socket.h>
#define MY_SOCK_PATH "/somepath"
#define LISTEN_BACKLOG 50
-#define handle_error(msg) \\
+#define handle_error(msg) \e
do { perror(msg); exit(EXIT_FAILURE); } while (0)
int
if (bind(sfd, (struct sockaddr *) &my_addr,
sizeof(struct sockaddr_un)) == \-1)
handle_error("bind");
-
+
if (listen(sfd, LISTEN_BACKLOG) == \-1)
handle_error("listen");
should be deleted using unlink(2) or remove(3) */
}
.fi
-.\"O .SH "SEE ALSO"
.SH 関連項目
-.BR accept (2),
-.BR connect (2),
-.BR getsockname (2),
-.BR listen (2),
-.BR socket (2),
-.BR getaddrinfo (3),
-.BR getifaddrs (3),
-.BR ip (7),
-.BR ipv6 (7),
-.BR path_resolution (7),
-.BR socket (7),
-.BR unix (7)
+\fBaccept\fP(2), \fBconnect\fP(2), \fBgetsockname\fP(2), \fBlisten\fP(2), \fBsocket\fP(2),
+\fBgetaddrinfo\fP(3), \fBgetifaddrs\fP(3), \fBip\fP(7), \fBipv6\fP(7),
+\fBpath_resolution\fP(7), \fBsocket\fP(7), \fBunix\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。