Updated on Kisan Patel
To check a remote server availability on the network using C#, you need to use the System.Net.NetworkInformation.Ping
class.
class Program { static void Main(string[] args) { System.Net.NetworkInformation.Ping pinger = new System.Net.NetworkInformation.Ping(); PingReply reply = pinger.Send("www.google.com"); Console.WriteLine("Results from pinging " + reply.Address); Console.WriteLine("Fragmentation allowed?: {0}", !reply.Options.DontFragment); Console.WriteLine("Time to live: {0}", reply.Options.Ttl); Console.WriteLine("Roundtrip took: {0}", reply.RoundtripTime); Console.WriteLine("Status: {0}", reply.Status.ToString()); Console.ReadKey(); } }
Output of the above program…