1GETSOCKNAME(3P)            POSIX Programmer's Manual           GETSOCKNAME(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

NAME

12       getsockname — get the socket name
13

SYNOPSIS

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

DESCRIPTION

21       The getsockname() function shall retrieve the locally-bound name of the
22       specified  socket, store this address in the sockaddr structure pointed
23       to by the address argument, and store the length of this address in the
24       object pointed to by the address_len argument.
25
26       The  address_len  argument  points to a socklen_t object which on input
27       specifies the length of the supplied sockaddr structure, and on  output
28       specifies  the  length  of the stored address.  If the actual length of
29       the address is greater than the length of the supplied sockaddr  struc‐
30       ture, the stored address shall be truncated.
31
32       If  the  socket has not been bound to a local name, the value stored in
33       the object pointed to by address is unspecified.
34

RETURN VALUE

36       Upon successful completion, 0 shall be returned, the  address  argument
37       shall  point to the address of the socket, and the address_len argument
38       shall point to the length  of  the  address.  Otherwise,  -1  shall  be
39       returned and errno set to indicate the error.
40

ERRORS

42       The getsockname() function shall fail if:
43
44       EBADF  The socket argument is not a valid file descriptor.
45
46       ENOTSOCK
47              The socket argument does not refer to a socket.
48
49       EOPNOTSUPP
50              The operation is not supported for this socket's protocol.
51
52       The getsockname() function may fail if:
53
54       EINVAL The socket has been shut down.
55
56       ENOBUFS
57              Insufficient  resources were available in the system to complete
58              the function.
59
60       The following sections are informative.
61

EXAMPLES

63       None.
64

APPLICATION USAGE

66       None.
67

RATIONALE

69       None.
70

FUTURE DIRECTIONS

72       None.
73

SEE ALSO

75       accept(), bind(), getpeername(), socket()
76
77       The Base Definitions volume of POSIX.1‐2017, <sys_socket.h>
78
80       Portions of this text are reprinted and reproduced in  electronic  form
81       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
82       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
83       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
84       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
85       event of any discrepancy between this version and the original IEEE and
86       The Open Group Standard, the original IEEE and The Open Group  Standard
87       is  the  referee document. The original Standard can be obtained online
88       at http://www.opengroup.org/unix/online.html .
89
90       Any typographical or formatting errors that appear  in  this  page  are
91       most likely to have been introduced during the conversion of the source
92       files to man page format. To report such errors,  see  https://www.ker
93       nel.org/doc/man-pages/reporting_bugs.html .
94
95
96
97IEEE/The Open Group                  2017                      GETSOCKNAME(3P)
Impressum