Matthew Bachmann <[EMAIL PROTECTED]> writes:

> I need to fetch a page into a string, and timout if it takes to long.
> 
> Here is my attempt.
> 
> 
> my $ua = LWP::UserAgent->new;
> $ua->timeout(1);
> my $url =  $urls{$server_num};
> my $return = $ua->request(GET $url)->as_string;
> 
> 
> This doesn't work.  It fetches the page fine, but it doesn't respect 
> the timeout.   If I try to fetch a page from a non-existant server, 
> it still tries for 30 seconds or so, then returns a string containing 
> an error message.  How do I get the code to use a timout, and what 
> will it return if the timout is triggered?

If you are running perl <= 5.005_03 try to upgrade the IO modules
first.  There are a known problem with the bundled stuff when it comes
to connect timeouts.

Regards,
Gisle

Reply via email to