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 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 argument sockfd is a file, not a socket.
41

CONFORMING TO

43       SVr4,  4.4BSD  (the  getsockname()  function  call appeared in 4.2BSD),
44       POSIX.1-2001.
45

NOTES

47       The third argument of getsockname() is in reality an int * (and this is
48       what  4.x BSD and libc4 and libc5 have).  Some POSIX confusion resulted
49       in the present socklen_t, also used by glibc.  See also accept(2).
50

SEE ALSO

52       bind(2), socket(2), getifaddrs(3), ip(7), socket(7), unix(7)
53

COLOPHON

55       This page is part of release 3.22 of the Linux  man-pages  project.   A
56       description  of  the project, and information about reporting bugs, can
57       be found at http://www.kernel.org/doc/man-pages/.
58
59
60
61Linux                             2008-12-03                    GETSOCKNAME(2)
Impressum