gioronco has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm trying to write a Perl script under Windows to perform parallel ping.
I would like to use one thread for each host that I have to ping.
I'm using Net::Ping and threads modules.
Threads main subroutine is something like that:
sub PingTest { my ($myhost, $protocol, $timeout) = @_; my $p = Net::Ping->new($protocol, $timeout); if (!$p->ping($myhost)) { print "Unreachable\n"; } else { print "Reachable\n"; } $p->close(); }
My problem is that if I use "tcp" as $protocol some hosts result Unreachable (but with windows command "ping" same hosts are reachable);
If I use "icmp" as $protocol all hosts are reachable (but with windows command "ping" some hosts are not reachable or not exist);
Have you got any suggests?
Thanks
G.

Replies are listed 'Best First'.
Re: Net::Ping on Windows
by moritz (Cardinal) on Oct 08, 2008 at 17:28 UTC
    My problem is that if I use "tcp" as $protocol some hosts result Unreachable (but with windows command "ping" same hosts are reachable);

    "tcp" will open a connection to the remote host's echo service (port 7), so if that's not open you won't get the results you want.

    If I use "icmp" as $protocol all hosts are reachable (but with windows command "ping" some hosts are not reachable or not exist);

    That's a bit weird - does it work without threads?

    Anyway, if you take your system's ping as reference, why not just use that (trough Net::Ping::External)?

Re: Net::Ping on Windows (oldie)
by tye (Sage) on Oct 09, 2008 at 07:19 UTC

    You might find some useful insights in Net::Ping, the mini series. Unfortunately, much covered there is still true, I believe (mea culpa).

    - tye