in reply to Re^3: My ping should fail but does not
in thread My ping should fail but does not
I've been trying your suggestion and different variations on it, and am not having much luck.
In the office, with high-speed connectivity, it generally seems to work as long as the $timeout value is high enough (something above 20), but not always. Sometimes, the ping just seems to die, with no return to the program. (In the office, a stand-alone ping usually shows about 10 ms turnaround.)
Working at home, with 56 kbps dial-up, it has died every time so far. But, here, the stand-alone ping is about 160 - 180 ms. I then raised the $timeout value to 900, but it still died within the ping. The code, results and stand-alone ping are shown below.
Is there something better than ping for determining connectivity to a remote host? As always, your help and insights are very much appreciated!!
use Net::Ping; # Global variables my $timeout = 90; # Time to wait for a response from ping # Part of sub -- printf "DB Server to be tested for accessibility: $dbSrvrBox\n\n"; # Ensure the connection to the DB Server is available if (!$dbSrvrBox) { printf ("Cannot find a boxname value in \"$_\" - Will abe +nd.\n\n"); # 2 }; next if (!$dbSrvrBox); printf "Ready to ping $dbSrvrBox\n\n"; if (ping($dbSrvrBox, $timeout)) { printf "DB Server ($dbSrvrBox) is accessible at startup. +\n\n"; &msgLog ("DB Server ($dbSrvrBox) is accessible at startup. +\n"); } else { printf ("Cannot access $dbSrvrBox - abending.\n\n"); + # 3 }; printf "After ping\n"; RESULTS (DOS Cmd window) -- DBSERVER0: \\PLYSDEV03\DEV03- DB Server to be tested for accessibility: PLYSDEV03 Ready to ping PLYSDEV03 C:\A_DRS_Proj\PerlCoding> STAND-ALONE PING -- C:\A_DRS_Proj\PerlCoding>ping PLYSDEV03 Pinging PLYSDEV03 [ ip ] with 32 bytes of data: Reply from [ ip ]: bytes=32 time=180ms TTL=125 Reply from [ ip ]: bytes=32 time=160ms TTL=125 Reply from [ ip ]: bytes=32 time=160ms TTL=125 Reply from [ ip ]: bytes=32 time=170ms TTL=125 Ping statistics for [ ip ]: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 160ms, Maximum = 180ms, Average = 167ms C:\A_DRS_Proj\PerlCoding>
|
---|