Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: PING taking too long

by rchiav (Deacon)
on Sep 25, 2001 at 18:28 UTC ( #114538=note: print w/replies, xml ) Need Help??

in reply to PING taking too long

Use the Net::Ping Module. You can specify the timeout value for the ping so it should be much faster. The module is failry simple to use and there's good examples in the documentation. One word of caution: I'd recomend only useing the ICMP ping. I've had troubles with TCP and UDP pings. From what I've found on the web, ICMP ping is the only one that works reliably.

Hope this helps,

Replies are listed 'Best First'.
Using Net::Ping
by Rhose (Priest) on Sep 25, 2001 at 18:47 UTC
    I would also try the Net::Ping module and use a defined timeout. Here is an example.

    use strict; use Net::Ping; use constant TIMEOUT => 1; my $mNetPing = Net::Ping->new('icmp',TIMEOUT); foreach ('host1', 'host2', '') { print $_,($mNetPing->ping($_) ? ' is alive' : ' is not alive'),"\n"; } $mNetPing->close();
Re: Re: PING taking too long
by mitd (Curate) on Sep 25, 2001 at 19:24 UTC
    Word of caution, on top of caution icmp usually requires suid root. tcp is prefered as it has the lowest overhead but tcp echo may be turned off at target hosts as a normal security necessity.

    see Re: Net::Ping just don't werk.

    mitd-Made in the Dark
    'My favourite colour appears to be grey.'

Re: Re: PING taking too long
by Hydro (Acolyte) on Sep 26, 2001 at 19:31 UTC
    I tried using Net::Ping but it doesn't seem to be working. If I print out $p->ping($ipaddress) where $ipaddress is a valid ip address on our network, all I get are zeros. Is there something I am doing wrong? Jonathan Southwick Allegheny College
      It's hard to tell if you're doing something wrong without seeing your code. Here's an example I just threw together that works. Note - this is on a windows 2000 box, so issues with being suid root aren't something I take into consideration.
      use strict; use warnings; use Net::Ping; my $p = Net::Ping->new('icmp', 1); my $result = $p->ping(''); print "Result is $result\n";
      If you're still having problems, post your code so we can figure out where things might be going wrong.


        Here is the situation. The PING works fine using the icmp protocol but not the tcp protocol in a perl script running directly from a linux bash console.

        When I use the same program as a cgi script running on the same server as when I executed the script on the console it does work. The icmp protocol makes it quit right away and the tcp protocol returns 0's for anything pinged.

        Jonathan Southwick Allegheny College

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2021-09-20 09:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found