Is it possible to impose a timeout on <>?

From: Bob Dubery (megapode_at_hotmail.com)
Date: 03/05/04


Date: 5 Mar 2004 00:35:20 -0800

Hi all

I have code that polls a number of machines on our network and
retrieves stats from each one.

This is done via HTTP

This morning the program hung. When I started investigating I found
that one of the remote machines was in some kind of strange state. You
could ping it. You coud connect to it (HTTP, Telnet, FTP) but you got
no response.

So my program opens up a socket, fires off the HTTP request and then
waits for a response from apache, and waits, and waits, and waits...

The relevant portion of the code looks like this...

  # open a socket...
  $socket = IO::Socket::INET->new(PeerAddr => $netaddr,
    PeerPort => 80,
    Proto => "tcp",
    Timeout => 10)
  or die "Couldn\'t open the socket!!!!";

# form the HTTP request
  $request = "GET $url HTTP\/1.0\n\n";

  # request the file...
  print $socket $request;

  # process the output and strip out the response headers
  $printit = 0;
  # ...now read the socket and process the output
   while($line = <$socket>){

# do some stuff with $line
   }

The program hangs at the <> operator.

OK... a wierd situation and not a common one, but I want to improve
the code. Specificially when I invoke <> I'd like to be able to impose
a time out so that if I get nothing back after n seconds I can raise
an error condition and start interrogating the next site.

TIA

Bob Dubery

PS... I have to post via Google, which is slow, so I might take a
while to see and respond to any questions.



Relevant Pages

  • Imposing a timeout on the <> operator - is this possible?
    ... This is done via HTTP ... that one of the remote machines was in some kind of strange state. ... So my program opens up a socket, fires off the HTTP request and then ...
    (comp.lang.perl)
  • Re: how to receive a Http message on a socket ?
    ... I need to receive a HTTP message on a socket: ... on a port and the browser sees me as its ... HTTP Request. ...
    (comp.os.linux.development.apps)
  • RE: HTTP DDoS attack on our servers
    ... First guess is that the machines you NMAP'd are victims of W32/Graps ... HTTP DDoS attack on our servers ... Basically,> 8.000 IP numbers are sending HTTP requests to our server on ... handle HTTP requests at all and immediately closed the connection after ...
    (Incidents)
  • RE: Cacheability issue with IE
    ... The downloads work fine under HTTP but under HTTPS I get an error on certain machines. ... My problem is that even if i set page cacheability on the event ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Web Hosting
    ... technologies you're using for you new website. ... If you're not running ISA and are using ICF... ... - You can publish number of HTTP ... >> client machines, but can only be reached via https from ...
    (microsoft.public.windows.server.sbs)