in reply to Net::ping is very unstable

In what way is it correct and in what way is it wrong?

Note that you are checking whether SYN packets reach the host and not ICMP packets.

Replies are listed 'Best First'.
Re^2: Net::ping is very unstable
by hxbsy (Novice) on Apr 09, 2015 at 11:41 UTC

    the host is pingable by OS's "ping" command,but not pingable by this script.
    but some hosts in other net is pingable by this script.

      The ping command sends ICMP packets. Your code sends SYN packets and expects ACK replies.

      I recommend you consult with your network administrator how to best check the connectivity between hosts on your network.

        I see.but I use "Net::Ping->new('icmp');",the script runs very slowly.
        in fact I check whether remote host opens specific port or not.for speed,I first have to use "Net::Ping" to check the host is alive or not.
        Can you give better advice?

      You can try to use Net::Ping::External, which actually invokes ping command.

      Creation of ICMP-packets requires special privileges on some systems (e.g. suid on linux), so, it is a bit not-convenient to use ICMP-protocol from perl. ping command already has that privilege/capability, and it is more-or-less safe to use it from security point of view.

      WBR, basiliscos.