For HTTP requests, there's a Client-Peer header that you can access in the response...
use LWP::UserAgent; use HTTP::Request::Common; my $url = 'http://www.perlmonks.org/'; my $browser = LWP::UserAgent->new; my $response = $browser->request( GET $url ); if ( $response->is_success ) { my($ip,$port) = split /:/, $response->header("Client-Peer"); print "Connected to $ip on port $port\n"; } else { print "Couldn't get $url: ", $response->status_line, "\n"; }
... although it dissappeared briefly before (and then re-appeared with) LWP 5.66, so you may need to upgrade, downgrade or hack LWP::Protocol::http if you find it's absent from the version you have installed.
--k.
In reply to Re: Get the IP Address
by Kanji
in thread Get the IP Address
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |