in reply to ping problem
However, you don't want to check if the server itself is up but if a specific service is up, so a refused connection is a failure to you. If you turn on 'tcp_service_check', Net::Ping will only report success if it could actually establish a connection, and report failture if the connection was denied.
Example:
use strict; use warnings; use Net::Ping; my $p = Net::Ping->new('tcp'); $p->tcp_service_check(1); my $host = "192.168.100.12"; my $port = 80; $p->{'port_num'} = $port; print "The service on $host port $port is ", ($p->ping($host) ? "up" : "down"), ".\n";
•Update: Note that the tcp_service_check option isn't available in the Net::Ping that is included with perl 5.8.0, however it is available in the latest version.
|
|---|