1getpeername(3SOCKET)       Sockets Library Functions      getpeername(3SOCKET)
2
3
4

NAME

6       getpeername - get name of connected peer
7

SYNOPSIS

9       cc [ flag ... ] file ... -lsocket  -lnsl  [ library ... ]
10       #include <sys/types.h>
11       #include <sys/socket.h>
12
13       int getpeername(int s, struct sockaddr *name, socklen_t *namelen);
14
15

DESCRIPTION

17       getpeername()  returns  the name of the peer connected to socket s. The
18       int pointed to by the namelen parameter should be initialized to  indi‐
19       cate  the amount of space pointed to by name. On return it contains the
20       actual size of the name returned (in bytes), prior to  any  truncation.
21       The name is truncated if the buffer provided is too small.
22

RETURN VALUES

24       If  successful,  getpeername() returns  0; otherwise it returns  −1 and
25       sets errno to indicate the error.
26

ERRORS

28       The call succeeds unless:
29
30       EBADF       The argument s is not a valid descriptor.
31
32
33       ENOMEM      There was insufficient user memory  for  the  operation  to
34                   complete.
35
36
37       ENOSR       There were insufficient STREAMS resources available for the
38                   operation to complete.
39
40
41       ENOTCONN    The socket is not connected.
42
43
44       ENOTSOCK    The argument s is not a socket.
45
46

ATTRIBUTES

48       See attributes(5) for descriptions of the following attributes:
49
50
51
52
53       ┌─────────────────────────────┬─────────────────────────────┐
54       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
55       ├─────────────────────────────┼─────────────────────────────┤
56       │MT-Level                     │Safe                         │
57       └─────────────────────────────┴─────────────────────────────┘
58

SEE ALSO

60       accept(3SOCKET), bind(3SOCKET), getsockname(3SOCKET),  socket(3SOCKET),
61       attributes(5), socket.h(3HEAD)
62
63
64
65SunOS 5.11                        26 Mar 1998             getpeername(3SOCKET)
Impressum