Returns the address of a connected peer.
#include <sys/socket.h> int getpeername ( int s, struct sockaddr *addr, size_t *len);
(IN) Specifies the socket file handle connected to the peer for which the addr argument is to be returned.
(OUT) Points to the location of the address for the peer connected to the socket. For IPv4, addr points to a sockaddr structure; for IPv6, to a sockaddr_in6 structure. The first two bytes in the structures identify the protocol family, and hence the structure.
(OUT) Points to the size of the address pointed to by addr.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:
The address is truncated if the buffer is too small.