~ubuntu-branches/ubuntu/precise/manpages-posix/precise

1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
2
.TH "GETPEERNAME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
3
.\" getpeername 
4
.SH NAME
5
getpeername \- get the name of the peer socket
6
.SH SYNOPSIS
7
.LP
8
\fB#include <sys/socket.h>
9
.br
10
.sp
11
int getpeername(int\fP \fIsocket\fP\fB, struct sockaddr *restrict\fP
12
\fIaddress\fP\fB,
13
.br
14
\ \ \ \ \ \  socklen_t *restrict\fP \fIaddress_len\fP\fB);
15
.br
16
\fP
17
.SH DESCRIPTION
18
.LP
19
The \fIgetpeername\fP() function shall retrieve the peer address of
20
the specified socket, store this address in the
21
\fBsockaddr\fP structure pointed to by the \fIaddress\fP argument,
22
and store the length of this address in the object pointed to
23
by the \fIaddress_len\fP argument.
24
.LP
25
If the actual length of the address is greater than the length of
26
the supplied \fBsockaddr\fP structure, the stored address
27
shall be truncated.
28
.LP
29
If the protocol permits connections by unbound clients, and the peer
30
is not bound, then the value stored in the object pointed
31
to by \fIaddress\fP is unspecified.
32
.SH RETURN VALUE
33
.LP
34
Upon successful completion, 0 shall be returned. Otherwise, -1 shall
35
be returned and \fIerrno\fP set to indicate the error.
36
.SH ERRORS
37
.LP
38
The \fIgetpeername\fP() function shall fail if:
39
.TP 7
40
.B EBADF
41
The \fIsocket\fP argument is not a valid file descriptor.
42
.TP 7
43
.B EINVAL
44
The socket has been shut down.
45
.TP 7
46
.B ENOTCONN
47
The socket is not connected or otherwise has not had the peer pre-specified.
48
.TP 7
49
.B ENOTSOCK
50
The \fIsocket\fP argument does not refer to a socket.
51
.TP 7
52
.B EOPNOTSUPP
53
The operation is not supported for the socket protocol.
54
.sp
55
.LP
56
The \fIgetpeername\fP() function may fail if:
57
.TP 7
58
.B ENOBUFS
59
Insufficient resources were available in the system to complete the
60
call.
61
.sp
62
.LP
63
\fIThe following sections are informative.\fP
64
.SH EXAMPLES
65
.LP
66
None.
67
.SH APPLICATION USAGE
68
.LP
69
None.
70
.SH RATIONALE
71
.LP
72
None.
73
.SH FUTURE DIRECTIONS
74
.LP
75
None.
76
.SH SEE ALSO
77
.LP
78
\fIaccept\fP() , \fIbind\fP() , \fIgetsockname\fP() , \fIsocket\fP()
79
, the Base Definitions volume of
80
IEEE\ Std\ 1003.1-2001, \fI<sys/socket.h>\fP
81
.SH COPYRIGHT
82
Portions of this text are reprinted and reproduced in electronic form
83
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
84
-- Portable Operating System Interface (POSIX), The Open Group Base
85
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
86
Electrical and Electronics Engineers, Inc and The Open Group. In the
87
event of any discrepancy between this version and the original IEEE and
88
The Open Group Standard, the original IEEE and The Open Group Standard
89
is the referee document. The original Standard can be obtained online at
90
http://www.opengroup.org/unix/online.html .