1GETSOCKNAME(2)             Linux Programmer's Manual            GETSOCKNAME(2)
2
3
4

NAME

6       getsockname - get socket name
7

SYNOPSIS

9       #include <sys/socket.h>
10
11       int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
12

DESCRIPTION

14       getsockname() returns the current address to which the socket sockfd is
15       bound, in the buffer pointed to by addr.  The addrlen  argument  should
16       be initialized to indicate the amount of space (in bytes) pointed to by
17       addr.  On return it contains the actual size of the socket address.
18
19       The returned address is truncated if the buffer provided is too  small;
20       in  this case, addrlen will return a value greater than was supplied to
21       the call.
22

RETURN VALUE

24       On success, zero is returned.  On error, -1 is returned, and  errno  is
25       set appropriately.
26

ERRORS

28       EBADF  The argument sockfd is not a valid file descriptor.
29
30       EFAULT The  addr  argument  points to memory not in a valid part of the
31              process address space.
32
33       EINVAL addrlen is invalid (e.g., is negative).
34
35       ENOBUFS
36              Insufficient resources were available in the system  to  perform
37              the operation.
38
39       ENOTSOCK
40              The file descriptor sockfd does not refer to a socket.
41

CONFORMING TO

43       POSIX.1-2001,  POSIX.1-2008, SVr4, 4.4BSD (getsockname() first appeared
44       in 4.2BSD).
45

NOTES

47       For background on the socklen_t type, see accept(2).
48

SEE ALSO

50       bind(2), socket(2), getifaddrs(3), ip(7), socket(7), unix(7)
51

COLOPHON

53       This page is part of release 4.15 of the Linux  man-pages  project.   A
54       description  of  the project, information about reporting bugs, and the
55       latest    version    of    this    page,    can     be     found     at
56       https://www.kernel.org/doc/man-pages/.
57
58
59
60Linux                             2017-09-15                    GETSOCKNAME(2)
Impressum