in reply to How to determine IP address of a remote connection?

Use one of the IO::Socket::INET documented methods

METHODS sockaddr () Return the address part of the sockaddr structure for the socket sockport () Return the port number that the socket is using on the local host sockhost () Return the address part of the sockaddr structure for the socket i +n a text form xx.xx.xx.xx peeraddr () Return the address part of the sockaddr structure for the socket o +n the peer host peerport () Return the port number for the socket on the peer host. peerhost () Return the address part of the sockaddr structure for the socket o +n the peer host in a text form xx.xx.xx.xx

Replies are listed 'Best First'.
Re^2: How to determine IP address of a remote connection?
by Zucan (Beadle) on Dec 02, 2004 at 16:21 UTC
    Okay, thanks...

    I tried peerhost() and got what I was looking for:

      my $IP = $SMTP->peerhost();
      print "Connected to $IP\n";
    

    It prints the IP address of the remote host as expected, and each run of the program shows a different IP, which all map back correctly to the original hostname.

    Thanks for the help!
    Zucan