Türkçe   |   English
Calendar
Categories
Archive
Links
Blogroll
Files

Pinging With .Net - 19.02.2009

You can easily ping an address with your .Net applications via a class came by .Net 2.0. I am sharing the code snippet with you which can be used for discovering whether a website is down or not.

C#

            System.Net.NetworkInformation.Ping png = new System.Net.NetworkInformation.Ping();
             try
 
            {
                 PingReply rply = png.Send("www.tameroz.com");
                 Console.Write(rply.RoundtripTime.ToString());
                 Console.ReadLine();
             }
             catch (Exception)
             {
                 Console.Write("Ping Error");
                 Console.ReadLine();
 
            }

 

VB.Net

 

        Dim png As New System.Net.NetworkInformation.Ping()
        Try
            Dim rply As PingReply = png.Send("www.tameroz.com")
            Console.Write(rply.RoundtripTime.ToString())
            Console.ReadLine()
        Catch generatedExceptionName As Exception
            Console.Write("Ping Error")
            Console.ReadLine()
        End Try

Clues,Codes

Add Comment
First Name Last Name
Web Site
E-Mail
Comment




Photos

San Francisco Street
Show All
Me in MSDN Forums
Entries
News
Articles