.net ping

By amer, October 24, 2008 2:12 am

So easy to ping in .net…

using System.Net.NetworkInformation;

private string pingHost(String hostip)
{
Ping pingSender = new Ping();
PingReply reply = pingSender.Send(hostip);
String str;
if (reply.Status == IPStatus.Success)
{
str = “”. Host is up”";
str += “”, Address: “” + reply.Address.ToString();
str += “”, RoundTrip time: “” + reply.RoundtripTime + “” ms.”";
}
else
str = “”. Host is down.”";
return str;
}


Related posts:

  1. Thank you, Sir! for better service.

Leave a Reply

Panorama theme by Themocracy