Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How do I tell if a remote site is up?

by sschneid (Deacon)
on Nov 11, 2003 at 17:36 UTC ( [id://306288]=note: print w/replies, xml ) Need Help??


in reply to How do I tell if a remote site is up?

Either ping it (using something like Net::Ping), or create a timeout wrapper around LWP:
local $SIG{ALRM} = sub { die }; eval { alarm(10); # LWP request alarm(0); };
-s.

Replies are listed 'Best First'.
Re: Re: How do I tell if a remote site is up?
by Elliott (Pilgrim) on Nov 11, 2003 at 18:21 UTC
    Sounds great - now what am I doing wrong?

    #!/usr/bin/perl use LWP::Simple; print "Content-type: text/html\n\n<html><body bgcolor=white>\n"; local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required eval { alarm 4; $content = get("http://select.worldpay.com/wcc/info?op=rates&instI +d=36128"); alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out print "timed out<BR>"; } else { # didn't print "succeeded<BR>"; } if($content) { print $content; } else { print "Durrr"; }

    It's still hanging.

    I haven't really understood how to use SIGALARM - I am just coding-by-numbers at the moment hoping that understanding will dawn.

      Ah.. I've tried it on a different server and it works perfectly. I wonder what the difference is.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://306288]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-23 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found