ASP
  Home arrow ASP arrow Page 5 - Using ASP & SQL To Ping A Remote Server
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Using ASP & SQL To Ping A Remote Server
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2001-11-28

    Table of Contents:
  • Using ASP & SQL To Ping A Remote Server
  • An overview of the procedure
  • Creating the stored procedure
  • The GetPingStats() ASP function
  • Analyzing the ping attempts
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using ASP & SQL To Ping A Remote Server - Analyzing the ping attempts


    (Page 5 of 6 )

    The data returned from the sp_PingServer will contain the details of the four ping attempts in rows 4 to 7, as shown below:

    The results of the four ping attempts

    The GetPingStats() function will break each line down to extract two things: the number of bytes sent per ping, and the time it took to reach its destination:

    if Instr(1, rsObject.Fields(0).value, "timed out") = 0 then 'successful

    'Get the number of bytes sent

    intNumBytes = Mid(rsObject.Fields(0).value, Instr(1, rsObject.Fields(0).value, "bytes=") + 6, Instr(1, rsObject.Fields(0).value, "time<") - (Instr(1, rsObject.Fields(0).value, "bytes=") +6)-1)

    intTime = Mid(rsObject.Fields(0).value, Instr(1, rsObject.Fields(0).value, "time<") + 5, Instr(1, rsObject.Fields(0).value, "TTL=") - (Instr(1, rsObject.Fields(0).value, "time<") +5)-3)

    intTotalTime = intTotalTime + intTime

    GetPingStats = GetPingStats & "Sent " & intNumBytes & " bytes, "

    GetPingStats = GetPingStats & "which took " & intTime & " milliseconds: "

    GetPingStats = GetPingStats & "<b>SUCCESS</b>"

    intNumSuccess = intNumSuccess + 1

    else 'The ping failed

    GetPingStats = GetPingStats & " Couldn't Connect: "

    GetPingStats = GetPingStats & "<b>FAILED</b>"

    end if


    Lastly, we create a summary of the ping attempts:

    'Add a final stats line to the return value

    GetPingStats = GetPingStats & "<br><b><u>Summary:</u></b><br>"

    GetPingStats = GetPingStats & intNumSuccess & " out of 4 pings successful<br>"

    GetPingStats = GetPingStats & "Took an average of " & intTotalTime / 4 & " milliseconds per ping<br><br>"

    GetPingStats = GetPingStats & "<hr>"


    When the function ends, the GetPingStats variable is automatically returned to the calling script, which simply outputs the value to the browser:

    if getIP = "true" then

    Response.Write DoPing(strHost)

    end if


    Calling the function with host I.P. 192.168.0.200, looks like this:

    The results of our GetPingStats() function

    More ASP Articles
    More By Mitchell Harper


     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek