Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LWP::UserAgent

Status
Not open for further replies.

tchatzi

Technical User
Joined
Dec 15, 2004
Messages
744
Location
GR
Hello everyone,
i just made a request with lwp::useragent and i was wondering if exept of the response, the host name and the ip, i can print also the port which the request is being to and which port the response is coming to.
as much as i searched the modules and the cpan i didn't find anything that i can understand.
Does anyone knows an easy way for solving my problem?

my $site = "
my $ua = LWP::UserAgent->new;

$ua->agent('MyApp/0.1');

my $request = HTTP::Request->new(GET => $site);
my $response = $ua->get($site,);

print $response->content,"\n";

my $ipsite = $site;
$ipsite =~ s/http:\/\///;
$ipsite =~ s/$ipsite =~ s/\/.*//;

my $addr = gethostbyname($ipsite);

if(not gethostbyname($ipsite)){
print "Hostname does NOT exist\n";
}
else {
print "Server Hostname: ",$ipsite,"\n";
printf "Hostname IP Address: %s \n", inet_ntoa($addr);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top