OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / 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 .\"*******************************************************************
41 .\"
42 .\" This file was generated with po4a. Translate the source file.
43 .\"
44 .\"*******************************************************************
45 .TH GETPEERNAME 2 2008\-12\-03 Linux "Linux Programmer's Manual"
46 .SH 名前
47 getpeername \- 接続している相手ソケットの名前を取得する
48 .SH 書式
49 \fB#include <sys/socket.h>\fP
50 .sp
51 \fBint getpeername(int \fP\fIsockfd\fP\fB, struct sockaddr *\fP\fIaddr\fP\fB, socklen_t
52 *\fP\fIaddrlen\fP\fB);\fP
53 .SH 説明
54 \fBgetpeername\fP()  は、ソケット(socket)  \fIsockfd\fP に接続している相手のアドレスを、 \fIaddr\fP
55 が指すバッファに格納して返す。 \fIaddrlen\fP 引き数は、 \fIaddr\fP が指している領域のサイズに初期化しておかなければならない。
56 関数が返る時には、 \fIaddrlen\fP には実際に返された名前のサイズが (バイト単位で) 格納される。
57 提供されたバッファが小さすぎた場合には、名前は切り詰められる。
58
59 渡されたバッファが小さ過ぎた場合は、返されるアドレスの末尾が切り詰められる。 この場合には、 \fIaddrlen\fP
60 には、呼び出し時に指定された値よりも大きな値が格納される。
61 .SH 返り値
62 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
63 .SH エラー
64 .TP 
65 \fBEBADF\fP
66 引き数 \fIsockfd\fP が有効なディスクリプタでない。
67 .TP 
68 \fBEFAULT\fP
69 \fIaddr\fP 引き数の指しているメモリが有効なプロセスのアドレス空間の 一部でない。
70 .TP 
71 \fBEINVAL\fP
72 \fIaddrlen\fP が不正である (例えば、負で場合など)。
73 .TP 
74 \fBENOBUFS\fP
75 この操作を行なうのに十分な資源がシステムに存在しない。
76 .TP 
77 \fBENOTCONN\fP
78 ソケットが接続していない。
79 .TP 
80 \fBENOTSOCK\fP
81 引き数 \fIsockfd\fP がソケットでなくてファイルである。
82 .SH 準拠
83 SVr4, 4.4BSD (\fBgetpeername\fP()  関数は 4.2BSD で登場した), POSIX.1\-2001.
84 .SH 注意
85 \fBgetpeername\fP()  の三番目の引き数は実際には \fI`int *'\fP である (4.x BSD, libc4, libc5 では
86 このようになっている)。 POSIX では紆余曲折を経て現在の \fIsocklen_t\fP になっており、 glibc でも \fIsocklen_t\fP
87 を使っている。 \fBaccept\fP(2)  も参照のこと。
88 .SH 関連項目
89 \fBaccept\fP(2), \fBbind\fP(2), \fBgetsockname\fP(2), \fBip\fP(7), \fBsocket\fP(7),
90 \fBunix\fP(7)