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
12 getsockname - get the socket name
13
15 #include <sys/socket.h>
16
17 int getsockname(int socket, struct sockaddr *restrict address,
18 socklen_t *restrict address_len);
19
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 If the actual length of the address is greater than the length of the
28 supplied sockaddr structure, the stored address shall be truncated.
29
30 If the socket has not been bound to a local name, the value stored in
31 the object pointed to by address is unspecified.
32
34 Upon successful completion, 0 shall be returned, the address argument
35 shall point to the address of the socket, and the address_len argument
36 shall point to the length of the address. Otherwise, -1 shall be
37 returned and errno set to indicate the error.
38
40 The getsockname() function shall fail if:
41
42 EBADF The socket argument is not a valid file descriptor.
43
44 ENOTSOCK
45 The socket argument does not refer to a socket.
46
47 EOPNOTSUPP
48 The operation is not supported for this socket's protocol.
49
50
51 The getsockname() function may fail if:
52
53 EINVAL The socket has been shut down.
54
55 ENOBUFS
56 Insufficient resources were available in the system to complete
57 the function.
58
59
60 The following sections are informative.
61
63 None.
64
66 None.
67
69 None.
70
72 None.
73
75 accept(), bind(), getpeername(), socket(), the Base Definitions volume
76 of IEEE Std 1003.1-2001, <sys/socket.h>
77
79 Portions of this text are reprinted and reproduced in electronic form
80 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
81 -- Portable Operating System Interface (POSIX), The Open Group Base
82 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
83 Electrical and Electronics Engineers, Inc and The Open Group. In the
84 event of any discrepancy between this version and the original IEEE and
85 The Open Group Standard, the original IEEE and The Open Group Standard
86 is the referee document. The original Standard can be obtained online
87 at http://www.opengroup.org/unix/online.html .
88
89
90
91IEEE/The Open Group 2003 GETSOCKNAME(3P)