1getpeername(3XNET)X/Open Networking Services Library Functionsgetpeername(3XNET)
2
3
4

NAME

6       getpeername - get the name of the peer socket
7

SYNOPSIS

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

DESCRIPTION

17       The  getpeername() function retrieves the peer address of the specified
18       socket, stores this address in the sockaddr structure pointed to by the
19       address  argument,  and stores the length of this address in the object
20       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 protocol permits connections by unbound clients, and the peer is
28       not bound, then the value stored in the object pointed to by address is
29       unspecified.
30

RETURN VALUES

32       Upon  successful  completion, 0 is returned.  Otherwise, −1 is returned
33       and errno is set to indicate the error.
34

ERRORS

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

ATTRIBUTES

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

SEE ALSO

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