1GETSOCKNAME(P)             POSIX Programmer's Manual            GETSOCKNAME(P)
2
3
4

NAME

6       getsockname - get the socket name
7

SYNOPSIS

9       #include <sys/socket.h>
10
11       int getsockname(int socket, struct sockaddr *restrict address,
12              socklen_t *restrict address_len);
13
14

DESCRIPTION

16       The getsockname() function shall retrieve the locally-bound name of the
17       specified socket, store this address in the sockaddr structure  pointed
18       to by the address argument, and store the length of this address in the
19       object pointed to by the address_len argument.
20
21       If the actual length of the address is greater than the length  of  the
22       supplied sockaddr structure, the stored address shall be truncated.
23
24       If  the  socket has not been bound to a local name, the value stored in
25       the object pointed to by address is unspecified.
26

RETURN VALUE

28       Upon successful completion, 0 shall be returned, the  address  argument
29       shall  point to the address of the socket, and the address_len argument
30       shall point to the length of  the  address.   Otherwise,  -1  shall  be
31       returned and errno set to indicate the error.
32

ERRORS

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

EXAMPLES

57       None.
58

APPLICATION USAGE

60       None.
61

RATIONALE

63       None.
64

FUTURE DIRECTIONS

66       None.
67

SEE ALSO

69       accept() , bind() , getpeername() , socket()  ,  the  Base  Definitions
70       volume of IEEE Std 1003.1-2001, <sys/socket.h>
71
73       Portions  of  this text are reprinted and reproduced in electronic form
74       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
75       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
76       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
77       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
78       event of any discrepancy between this version and the original IEEE and
79       The  Open Group Standard, the original IEEE and The Open Group Standard
80       is the referee document. The original Standard can be  obtained  online
81       at http://www.opengroup.org/unix/online.html .
82
83
84
85IEEE/The Open Group                  2003                       GETSOCKNAME(P)
Impressum