]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/getpeername.2
Updated CONFORMING TO section
[thirdparty/man-pages.git] / 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@gmx.net>
38 .\" Added 'socket' to NAME, so that "man -k socket" will show this page.
39 .\"
40 .TH GETPEERNAME 2 1993-07-30 "BSD Man Page" "Linux Programmer's Manual"
41 .SH NAME
42 getpeername \- get name of connected peer socket
43 .SH SYNOPSIS
44 .B #include <sys/socket.h>
45 .sp
46 .BI "int getpeername(int " s ", struct sockaddr *" name ", socklen_t *" namelen );
47 .SH DESCRIPTION
48 .BR getpeername ()
49 returns the name of the peer connected to socket
50 .IR s .
51 The
52 .I namelen
53 parameter should be initialized to indicate the amount of space pointed to
54 by
55 .IR name .
56 On return it contains the actual size of the name returned (in bytes). The
57 name is truncated if the buffer provided is too small.
58 .SH "RETURN VALUE"
59 On success, zero is returned. On error, \-1 is returned, and
60 .I errno
61 is set appropriately.
62 .SH ERRORS
63 .TP
64 .B EBADF
65 The argument
66 .I s
67 is not a valid descriptor.
68 .TP
69 .B EFAULT
70 The
71 .I name
72 parameter points to memory not in a valid part of the
73 process address space.
74 .TP
75 .B EINVAL
76 .I namelen
77 is invalid (e.g., is negative).
78 .TP
79 .B ENOBUFS
80 Insufficient resources were available in the system
81 to perform the operation.
82 .TP
83 .B ENOTCONN
84 The socket is not connected.
85 .TP
86 .B ENOTSOCK
87 The argument
88 .I s
89 is a file, not a socket.
90 .SH "CONFORMING TO"
91 SVr4, 4.4BSD (the
92 .BR getpeername ()
93 function call first appeared in 4.2BSD), POSIX.1-2001.
94 .SH NOTE
95 The third argument of
96 .BR getpeername ()
97 is in reality an
98 .I int *
99 (and this is what 4.x BSD and libc4 and libc5 have).
100 Some POSIX confusion resulted in the present
101 .IR socklen_t ,
102 also used by glibc.
103 See also
104 .BR accept (2).
105 .SH "SEE ALSO"
106 .BR accept (2),
107 .BR bind (2),
108 .BR getsockname (2)