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 }