You are viewing the version of this documentation from Perl 5.20.1. View the latest version
getpeername SOCKET

Returns the packed sockaddr address of the other end of the SOCKET connection.

use Socket;
$hersockaddr    = getpeername(SOCK);
($port, $iaddr) = sockaddr_in($hersockaddr);
$herhostname    = gethostbyaddr($iaddr, AF_INET);
$herstraddr     = inet_ntoa($iaddr);
init