getpeername(2) — 4 BSD
NAME
getpeername − get name of connected peer
SYNOPSIS
int getpeername (s, name, namelen)
int s;
struct sockaddr ∗name;
int ∗namelen;
DESCRIPTION
getpeername returns the name of the peer connected to socket s. The namelen parameter 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).
RETURN VALUE
If the calls succeed, a value of 0 is returned. If an error occurs, the value −1 is returned, and a more precise error code is placed in the global variable errno.
ERRORS
The call succeeds unless:
[EBADF] The argument s is not a valid descriptor.
[ENOTSOCK] The argument 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 name parameter points to memory not in a valid part of the process address space. This call is defined in the 88open Binary and Object Compatibility Standards’ Networking Supplements (BCSNS and OCSNS) for use in BCSNS/OCSNS compliant applications. OCSNS-defined functions may be accessed by passing OCS options to cc(1) and ld(1).
SEE ALSO
bind(2), socket(2), getsockname(2)
CX/UX Programmer’s Reference Manual