Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Checking Server Availability

by Desdinova (Friar)
on Mar 12, 2003 at 08:53 UTC ( [id://242288]=note: print w/replies, xml ) Need Help??


in reply to Checking Server Availability

THe above advice is the way that I would go.. Just to throw my 1/50th of dollar in.. You mention using ping, for just checking connectivity this is fine, but even if you can ping it it doesn't mean the service you are going to use is up. I have had machines that ping fine but have had the ftpd or httpd process die an untimely death.

I think the best approach is to test the conncetion to the service you need, and like any good network code make sure there is a timeout that is monitored so that if the connection fails the program acknoledges that and moves along.

Replies are listed 'Best First'.
Re: Re: Checking Server Availability
by Anonymous Monk on Mar 12, 2003 at 15:31 UTC
    OK, sounds like lots of folks think IO::Socket and/or IO::Socket::INET is the way to go. So is this the kind of thing you recommend?

    use IO::Socket; use IO::Socket::INET; my $socket = IO::Socket::INET->new( PeerAdr => $my_server, PeerPort => 'ftp(21)', #might be http(80) someday Proto => 'tcp'); my $is_connected = $socket->connected(); $socket->shutdown(2); if(!$is_connected){ #go back to sleep } else{ #do some stuff }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found