Doing "ping" inside my c # application

I need my application for the ping address, which I will specify later, and just simply copy the Average Ping Time into the .Text label.

Any help?

EDIT:

I found a solution in case anyone is interested:

Ping pingClass = new Ping(); PingReply pingReply = pingClass.Send("logon.chronic-domination.com"); label4.Text = (pingReply.RoundtripTime.ToString() + "ms"); 
+13
c # ping
Aug 15 '09 at 4:47
source share
2 answers

Take a look at the NetworkInformation.Ping class.

Example:

Using:

 PingTimeAverage("stackoverflow.com", 4); 

Implementation:

 public static double PingTimeAverage(string host, int echoNum) { long totalTime = 0; int timeout = 120; Ping pingSender = new Ping (); for (int i = 0; i < echoNum; i++) { PingReply reply = pingSender.Send (host, timeout); if (reply.Status == IPStatus.Success) { totalTime += reply.RoundtripTime; } } return totalTime / echoNum; } 
+32
Aug 15 '09 at 4:51
source share

As well as a side effect. There is a ready-made project on how sourceforge does what you want. It also included an implementation of ICMP (RFC 792)

Sourceforge Project

0
Jan 26 '10 at 16:32
source share



All Articles