in reply to Hard timeout for LWP::UserAgent or similar
What's wrong with the built-in timeout?
#! perl -slw use strict; use Time::HiRes qw[ time ]; use LWP; my $ua = LWP::UserAgent->new; $ua->timeout( 0.1 ); print time; my $response = $ua->get('http://192.168.1.31/noexist.html'); print time; if ($response->is_success) { print $response->decoded_content; # or whatever } else { die $response->status_line; } __END__ C:\test>junk76 1301504675.567 1301504675.74173 500 Can't connect to 192.168.1.31:80 (connect: timeout) at C:\test\jun +k76.pl line 17.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hard timeout for LWP::UserAgent or similar
by camelobserver (Initiate) on Mar 30, 2011 at 17:59 UTC | |
by BrowserUk (Patriarch) on Mar 31, 2011 at 01:45 UTC |