public static void ComplexLocalPing () { // Ping's the local machine. Ping pingSender = new Ping (); IPAddress address = IPAddress.Loopback; // Create a buffer of 32 bytes of data to be transmitted. string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; byte[] buffer = Encoding.ASCII.GetBytes (data); // Wait 10 seconds for a reply. int timeout = 10000; // Set options for transmission: // The data can go through 64 gateways or routers // before it is destroyed, and the data packet // cannot be fragmented. PingOptions options = new PingOptions (64, true); PingReply reply = pingSender.Send (address, timeout, buffer, options); if (reply.Status == IPStatus.Success) { Console.WriteLine ("Address: {0}", reply.Address.ToString ()); Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime); Console.WriteLine ("Time to live: {0}", reply.Options.Ttl); Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment); Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length); } else { Console.WriteLine (reply.Status); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)