in reply to Get the IP Address
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Get the IP Address
by Anonymous Monk on Aug 26, 2003 at 23:28 UTC | |
by jdtoronto (Prior) on Aug 27, 2003 at 01:48 UTC |