1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .\" @(#)getpeername.2 6.5 (Berkeley) 3/10/91
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.
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>
50 .\"WORD: descriptor ディスクリプタ
53 .TH GETPEERNAME 2 2008-12-03 "Linux" "Linux Programmer's Manual"
56 .\"O getpeername \- get name of connected peer socket
57 getpeername \- 接続している相手ソケットの名前を取得する
60 .B #include <sys/socket.h>
62 .BI "int getpeername(int " sockfd ", struct sockaddr *" addr \
63 ", socklen_t *" addrlen );
66 .\"O .BR getpeername ()
67 .\"O returns the address of the peer connected to the socket
69 .\"O in the buffer pointed to by
79 .\"O argument should be initialized to indicate the amount of space pointed to
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.
90 には実際に返された名前のサイズが (バイト単位で) 格納される。
91 提供されたバッファが小さすぎた場合には、名前は切り詰められる。
93 .\"O The returned address is truncated if the buffer provided is too small;
96 .\"O will return a value greater than was supplied to the call.
97 渡されたバッファが小さ過ぎた場合は、返されるアドレスの末尾が切り詰められる。
100 には、呼び出し時に指定された値よりも大きな値が格納される。
101 .\"O .SH "RETURN VALUE"
103 .\"O On success, zero is returned.
104 .\"O On error, \-1 is returned, and
106 .\"O is set appropriately.
107 成功した場合は 0 が返される。エラーの場合は \-1 が返され、
116 .\"O is not a valid descriptor.
124 .\"O argument points to memory not in a valid part of the
125 .\"O process address space.
127 引き数の指しているメモリが有効なプロセスのアドレス空間の
132 .\"O is invalid (e.g., is negative).
137 .\"O Insufficient resources were available in the system
138 .\"O to perform the operation.
139 この操作を行なうのに十分な資源がシステムに存在しない。
142 .\"O The socket is not connected.
148 .\"O is a file, not a socket.
152 .\"O .SH "CONFORMING TO"
154 .\"O SVr4, 4.4BSD (the
155 .\"O .BR getpeername ()
156 .\"O function call first appeared in 4.2BSD), POSIX.1-2001.
159 関数は 4.2BSD で登場した), POSIX.1-2001.
162 .\"O The third argument of
163 .\"O .BR getpeername ()
164 .\"O is in reality an
166 .\"O (and this is what 4.x BSD and libc4 and libc5 have).
167 .\"O Some POSIX confusion resulted in the present
169 .\"O also used by glibc.
175 である (4.x BSD, libc4, libc5 では