http://qs321.pair.com?node_id=350

getpeername

See the current Perl documentation for getpeername.

Here is our local, out-dated (pre-5.6) version:


getpeername - find the other hend of a socket connection



getpeername SOCKET



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

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