getpeername(2)
NAME
getpeername − get name of connected peer
SYNTAX
int getpeername(s, name, namelen)
int s, *namelen;
struct sockaddr *name;
DESCRIPTION
The getpeername system call returns the name of the peer connected to socket s. The specified namelen should be initialized to indicate the amount of space pointed to by name. On return, it contains the actual size of the name returned (in bytes).
RESTRICTIONS
Names bound to sockets in the UNIX domain are inaccessible. The getpeername call returns a zero length name.
RETURN VALUE
If unsuccessful, returns a −1, and the global variable errno indicates the error code.
DIAGNOSTICS
The getpeername call will fail if:
[EBADF] The specified s is not a valid descriptor.
[ENOTSOCK] The specified s is a file, not a socket.
[ENOTCONN] The socket is not connected.
[ENOBUFS] Insufficient resources were available in the system to perform the operation.
[EFAULT] The specified name points to memory that is not in a valid part of the process address space.