1GETSOCKNAME(3P) POSIX Programmer's Manual GETSOCKNAME(3P)
2
3
4
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
13 getsockname — get the socket name
14
16 #include <sys/socket.h>
17
18 int getsockname(int socket, struct sockaddr *restrict address,
19 socklen_t *restrict address_len);
20
22 The getsockname() function shall retrieve the locally-bound name of the
23 specified socket, store this address in the sockaddr structure pointed
24 to 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 socket has not been bound to a local name, the value stored in
34 the object pointed to by address is unspecified.
35
37 Upon successful completion, 0 shall be returned, the address argument
38 shall point to the address of the socket, and the address_len argument
39 shall point to the length of the address. Otherwise, −1 shall be
40 returned and errno set to indicate the error.
41
43 The getsockname() function shall fail if:
44
45 EBADF The socket argument is not a valid file descriptor.
46
47 ENOTSOCK
48 The socket argument does not refer to a socket.
49
50 EOPNOTSUPP
51 The operation is not supported for this socket's protocol.
52
53 The getsockname() function may fail if:
54
55 EINVAL The socket has been shut down.
56
57 ENOBUFS
58 Insufficient resources were available in the system to complete
59 the function.
60
61 The following sections are informative.
62
64 None.
65
67 None.
68
70 None.
71
73 None.
74
76 accept(), bind(), getpeername(), socket()
77
78 The Base Definitions volume of POSIX.1‐2008, <sys_socket.h>
79
81 Portions of this text are reprinted and reproduced in electronic form
82 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
83 -- Portable Operating System Interface (POSIX), The Open Group Base
84 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
85 cal and Electronics Engineers, Inc and The Open Group. (This is
86 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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
90 at http://www.unix.org/online.html .
91
92 Any typographical or formatting errors that appear in this page are
93 most likely to have been introduced during the conversion of the source
94 files to man page format. To report such errors, see https://www.ker‐
95 nel.org/doc/man-pages/reporting_bugs.html .
96
97
98
99IEEE/The Open Group 2013 GETSOCKNAME(3P)