OSDN Git Service

b7b30b3aa72766219ac93f932d47bf4c02633963
[linuxjm/LDP_man-pages.git] / draft / man2 / getpeername.2
1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)getpeername.2       6.5 (Berkeley) 3/10/91
33 .\"
34 .\" Modified Sat Jul 24 16:37:50 1993 by Rik Faith <faith@cs.unc.edu>
35 .\" Modified Thu Jul 30 14:37:50 1993 by Martin Schulze <joey@debian.org>
36 .\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer <aeb@cwi.nl>
37 .\" Modified 17 Jul 2002, Michael Kerrisk <mtk.manpages@gmail.com>
38 .\"     Added 'socket' to NAME, so that "man -k socket" will show this page.
39 .\"
40 .\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
41 .\"         all rights reserved.
42 .\" Translated Sat Apr  3 14:53:19 JST 1999
43 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
44 .\" Updated Tue Nov 26 JST 2002 by Kentaro Shirakata <argrath@ub32.org>
45 .\"
46 .\"WORD:        connect                 接続
47 .\"WORD:        peer                    相手
48 .\"WORD:        socket                  ソケット
49 .\"WORD:        buffer                  バッファ
50 .\"WORD:        descriptor              ディスクリプタ
51 .\"WORD:        argument                引き数
52 .\"
53 .TH GETPEERNAME 2 2008-12-03 "Linux" "Linux Programmer's Manual"
54 .\"O .SH NAME
55 .SH 名前
56 .\"O getpeername \- get name of connected peer socket
57 getpeername \- 接続している相手ソケットの名前を取得する
58 .\"O .SH SYNOPSIS
59 .SH 書式
60 .B #include <sys/socket.h>
61 .sp
62 .BI "int getpeername(int " sockfd ", struct sockaddr *" addr \
63 ", socklen_t *" addrlen );
64 .\"O .SH DESCRIPTION
65 .SH 説明
66 .\"O .BR getpeername ()
67 .\"O returns the address of the peer connected to the socket
68 .\"O .IR sockfd ,
69 .\"O in the buffer pointed to by
70 .\"O .IR addr .
71 .BR getpeername ()
72 は、ソケット(socket)
73 .I sockfd
74 に接続している相手のアドレスを、
75 .I addr
76 が指すバッファに格納して返す。
77 .\"O The
78 .\"O .I addrlen
79 .\"O argument should be initialized to indicate the amount of space pointed to
80 .\"O by
81 .\"O .IR addr .
82 .I addrlen
83 引き数は、
84 .I addr
85 が指している領域のサイズに初期化しておかなければならない。
86 .\"O On return it contains the actual size of the name returned (in bytes).
87 .\"O The name is truncated if the buffer provided is too small.
88 関数が返る時には、
89 .I addrlen
90 には実際に返された名前のサイズが (バイト単位で) 格納される。
91 提供されたバッファが小さすぎた場合には、名前は切り詰められる。
92
93 .\"O The returned address is truncated if the buffer provided is too small;
94 .\"O in this case,
95 .\"O .I addrlen
96 .\"O will return a value greater than was supplied to the call.
97 渡されたバッファが小さ過ぎた場合は、返されるアドレスの末尾が切り詰められる。
98 この場合には、
99 .I addrlen
100 には、呼び出し時に指定された値よりも大きな値が格納される。
101 .\"O .SH "RETURN VALUE"
102 .SH 返り値
103 .\"O On success, zero is returned.
104 .\"O On error, \-1 is returned, and
105 .\"O .I errno
106 .\"O is set appropriately.
107 成功した場合は 0 が返される。エラーの場合は \-1 が返され、
108 .I errno
109 を適切に設定する。
110 .\"O .SH ERRORS
111 .SH エラー
112 .TP
113 .B EBADF
114 .\"O The argument
115 .\"O .I sockfd
116 .\"O is not a valid descriptor.
117 引き数
118 .I sockfd
119 が有効なディスクリプタでない。
120 .TP
121 .B EFAULT
122 .\"O The
123 .\"O .I addr
124 .\"O argument points to memory not in a valid part of the
125 .\"O process address space.
126 .I addr
127 引き数の指しているメモリが有効なプロセスのアドレス空間の
128 一部でない。
129 .TP
130 .B EINVAL
131 .\"O .I addrlen
132 .\"O is invalid (e.g., is negative).
133 .I addrlen
134 が不正である (例えば、負で場合など)。
135 .TP
136 .B ENOBUFS
137 .\"O Insufficient resources were available in the system
138 .\"O to perform the operation.
139 この操作を行なうのに十分な資源がシステムに存在しない。
140 .TP
141 .B ENOTCONN
142 .\"O The socket is not connected.
143 ソケットが接続していない。
144 .TP
145 .B ENOTSOCK
146 .\"O The argument
147 .\"O .I sockfd
148 .\"O is a file, not a socket.
149 引き数
150 .I sockfd
151 がソケットでなくてファイルである。
152 .\"O .SH "CONFORMING TO"
153 .SH 準拠
154 .\"O SVr4, 4.4BSD (the
155 .\"O .BR getpeername ()
156 .\"O function call first appeared in 4.2BSD), POSIX.1-2001.
157 SVr4, 4.4BSD
158 .RB ( getpeername ()
159 関数は 4.2BSD で登場した), POSIX.1-2001.
160 .\"O .SH NOTES
161 .SH 注意
162 .\"O The third argument of
163 .\"O .BR getpeername ()
164 .\"O is in reality an
165 .\"O .I int *
166 .\"O (and this is what 4.x BSD and libc4 and libc5 have).
167 .\"O Some POSIX confusion resulted in the present
168 .\"O .IR socklen_t ,
169 .\"O also used by glibc.
170 .\"O See also
171 .\"O .BR accept (2).
172 .BR getpeername ()
173 の三番目の引き数は実際には
174 .I `int *'
175 である (4.x BSD, libc4, libc5 では
176 このようになっている)。
177 POSIX では紆余曲折を経て現在の
178 .I socklen_t
179 になっており、
180 glibc でも
181 .I socklen_t
182 を使っている。
183 .BR accept (2)
184 も参照のこと。
185 .\"O .SH "SEE ALSO"
186 .SH 関連項目
187 .BR accept (2),
188 .BR bind (2),
189 .BR getsockname (2),
190 .BR ip (7),
191 .BR socket (7),
192 .BR unix (7)