1getsockname(3XNET)X/Open Networking Services Library Functionsgetsockname(3XNET)
2
3
4

NAME

6       getsockname - get the socket name
7

SYNOPSIS

9       cc [ flag ... ] file ... -lxnet [ library ... ]
10       #include <sys/socket.h>
11
12       int getsockname(int socket, struct sockaddr *restrict address,
13            socklen_t *restrict address_len);
14
15

DESCRIPTION

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

RETURN VALUES

31       Upon successful completion, 0 is returned, the address argument  points
32       to  the  address  of the socket, and the address_len argument points to
33       the length of the address.  Otherwise, −1 is returned and errno is  set
34       to indicate the error.
35

ERRORS

37       The getsockname() function will fail:
38
39       EBADF         The socket argument is not a valid file descriptor.
40
41
42       EFAULT        The    address  or   address_len  parameter  can  not  be
43                     accessed or written.
44
45
46       ENOTSOCK      The socket argument does not refer to a socket.
47
48
49       EOPNOTSUPP    The operation is not supported for this  socket's  proto‐
50                     col.
51
52
53
54       The getsockname() function may fail if:
55
56       EINVAL     The socket has been shut down.
57
58
59       ENOBUFS    Insufficient  resources were available in the system to com‐
60                  plete the call.
61
62
63       ENOSR      There were insufficient STREAMS resources available for  the
64                  operation to complete.
65
66

ATTRIBUTES

68       See attributes(5) for descriptions of the following attributes:
69
70
71
72
73       ┌─────────────────────────────┬─────────────────────────────┐
74       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
75       ├─────────────────────────────┼─────────────────────────────┤
76       │Interface Stability          │Standard                     │
77       ├─────────────────────────────┼─────────────────────────────┤
78       │MT-Level                     │MT-Safe                      │
79       └─────────────────────────────┴─────────────────────────────┘
80

SEE ALSO

82       accept(3XNET),     bind(3XNET),    getpeername(3XNET),    socket(3XNET)
83       attributes(5), standards(5)
84
85
86
87SunOS 5.11                        10 Jun 2002               getsockname(3XNET)
Impressum