Re: timeout

"Octavian Rasnita" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <003701c70382$a0df2980$9f65fea9@ted>
Hi,

I've also tried without that "-" before "timeout", but it doesn't work. I
have also tried with $ua->timeout(5), but it doesn't work either.

Here is the test script and its result:

use strict;
use LWP::UserAgent;

my $begin = time();

my $ua = LWP::UserAgent->new();
$ua->timeout(5);

print $ua->get("http://www.presaromana.ro/")->content;

print time() - $begin;

And the result is:
500 Can't connect to www.presaromana.ro:80 (connect: Unknown error)
23

So it takes 23 seconds instead of timing out after 5.

Is it a bug in LWP, or a limitation of Windows, or I am doing something
wrong?

Thank you.

Teddy

----- Original Message ----- 
From: "Ted Behling" <[email protected]>
To: "Octavian Rasnita" <[email protected]>; <[email protected]>
Sent: Wednesday, November 08, 2006 8:22 PM
Subject: RE: timeout


True.  Or, Octavian, just leave out the hyphen from your timeout
parameter, as in:

my $ua = LWP::UserAgent->new(timeout => 5);

Ted Behling
ISP Systems Analyst, Hargray Communications
[email protected]

-----Original Message-----
From: Eamon Daly [mailto:[email protected]]
Sent: Wednesday, November 08, 2006 10:36 AM
To: [email protected]
Cc: Octavian Rasnita
Subject: Re: timeout

From the LWP::UserAgent perldoc at

http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP/UserAgent.pm

  $ua->timeout( $secs )
    Get/set the timeout value in seconds. The default timeout() value is
180 seconds, i.e. 3 minutes.

So in your first example, it should be:

  use strict;
  use LWP::UserAgent;

  my $ua = LWP::UserAgent->new;
  $ua->timeout(5);

  print $ua->get("http://www.presaromana.ro/")->content;

____________________________________________________________
Eamon Daly



----- Original Message -----
From: "Octavian Rasnita" <[email protected]>
To: <[email protected]>
Sent: Wednesday, November 08, 2006 8:37 AM
Subject: timeout


: Hi,
:
: I am trying to create a very simple www client that times out after 5
: seconds. I have tried the 2 examples below, but none of them are
working.
: They don't time out even though the target site cannot be found.
: I think they time out after some more time.
:
: I have ran them under Windows 2000 with ActivePerl 5.8.8.
: Is it possible to do what I want?
:
: Thanks.
:
: use strict;
: use LWP::UserAgent;
:
: my $ua = LWP::UserAgent->new(-timeout => 5);
:
: print $ua->get("http://www.presaromana.ro/")->content;
:
: __END__
:
: my $req = HTTP::Request->new("GET", "http://www.presaromana.ro/");
: my $res = $ua->request($req);
:
: print $res->content();
:
:
: Teddy
:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.