1GETPEERNAME(3P)            POSIX Programmer's Manual           GETPEERNAME(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       getpeername — get the name of the peer socket
14

SYNOPSIS

16       #include <sys/socket.h>
17
18       int getpeername(int socket, struct sockaddr *restrict address,
19           socklen_t *restrict address_len);
20

DESCRIPTION

22       The getpeername() function shall retrieve the peer address of the spec‐
23       ified  socket,  store this address in the sockaddr structure pointed to
24       by the address argument, and store the length of this  address  in  the
25       object pointed to by the address_len argument.
26
27       The  address_len  argument  points to a socklen_t object which on input
28       specifies the length of the supplied sockaddr structure, and on  output
29       specifies  the  length  of the stored address.  If the actual length of
30       the address is greater than the length of the supplied sockaddr  struc‐
31       ture, the stored address shall be truncated.
32
33       If the protocol permits connections by unbound clients, and the peer is
34       not bound, then the value stored in the object pointed to by address is
35       unspecified.
36

RETURN VALUE

38       Upon successful completion, 0 shall be returned. Otherwise, −1 shall be
39       returned and errno set to indicate the error.
40

ERRORS

42       The getpeername() function shall fail if:
43
44       EBADF  The socket argument is not a valid file descriptor.
45
46       EINVAL The socket has been shut down.
47
48       ENOTCONN
49              The socket is not connected or otherwise has not  had  the  peer
50              pre-specified.
51
52       ENOTSOCK
53              The socket argument does not refer to a socket.
54
55       EOPNOTSUPP
56              The operation is not supported for the socket protocol.
57
58       The getpeername() function may fail if:
59
60       ENOBUFS
61              Insufficient  resources were available in the system to complete
62              the call.
63
64       The following sections are informative.
65

EXAMPLES

67       None.
68

APPLICATION USAGE

70       None.
71

RATIONALE

73       None.
74

FUTURE DIRECTIONS

76       None.
77

SEE ALSO

79       accept(), bind(), getsockname(), socket()
80
81       The Base Definitions volume of POSIX.1‐2008, <sys_socket.h>
82
84       Portions of this text are reprinted and reproduced in  electronic  form
85       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
86       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
87       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
88       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
89       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
90       event of any discrepancy between this version and the original IEEE and
91       The  Open Group Standard, the original IEEE and The Open Group Standard
92       is the referee document. The original Standard can be  obtained  online
93       at http://www.unix.org/online.html .
94
95       Any  typographical  or  formatting  errors that appear in this page are
96       most likely to have been introduced during the conversion of the source
97       files  to  man page format. To report such errors, see https://www.ker
98       nel.org/doc/man-pages/reporting_bugs.html .
99
100
101
102IEEE/The Open Group                  2013                      GETPEERNAME(3P)
Impressum