1GETPEERNAME(2)             Linux Programmer's Manual            GETPEERNAME(2)
2
3
4

NAME

6       getpeername - get name of connected peer socket
7

SYNOPSIS

9       #include <sys/socket.h>
10
11       int getpeername(int s, struct sockaddr *name, socklen_t *namelen);
12

DESCRIPTION

14       getpeername()  returns the name of the peer connected to socket s.  The
15       namelen parameter should be initialized to indicate the amount of space
16       pointed  to by name.  On return it contains the actual size of the name
17       returned (in bytes).  The name is truncated if the buffer  provided  is
18       too small.
19

RETURN VALUE

21       On  success,  zero is returned.  On error, -1 is returned, and errno is
22       set appropriately.
23

ERRORS

25       EBADF  The argument s is not a valid descriptor.
26
27       EFAULT The name parameter points to memory not in a valid part  of  the
28              process address space.
29
30       EINVAL namelen is invalid (e.g., is negative).
31
32       ENOBUFS
33              Insufficient  resources  were available in the system to perform
34              the operation.
35
36       ENOTCONN
37              The socket is not connected.
38
39       ENOTSOCK
40              The argument s is a file, not a socket.
41

CONFORMING TO

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

NOTE

47       The third argument of getpeername() 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       accept(2), bind(2), getsockname(2)
53
54
55
56BSD Man Page                      1993-07-30                    GETPEERNAME(2)
Impressum