Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks Both:

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>

In reply to Re^4: My ping should fail but does not by mike at rcn
in thread My ping should fail but does not by mike at rcn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2023-02-09 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (45 votes). Check out past polls.

    Notices?