Check the availability of connectivity of particular Server or IP or HOST.

In many applications we need to use internet for sending and receiving data, for that we need to check the connectivity first.

Below code checks the availability of connectivity of particular server or IP or HOST.

using System.Net.NetworkInformation;

protected void Page_Load(object sender, EventArgs e)
{

Ping png = new Ping();

PingReply response;

String ip = “183.150.27.27”;  //Example : “www.yahoo.com”;

response  = png.Send(ip,60000);

Response.Buffer = false;

if (response.Status == IPStatus.Success)
{
Response.Write(“Ping to ” + ip.ToString() + “[” + response.Address.ToString() + “] is  successful – ” +”Recieved “+
Response.Buffer.Length.ToString() + ” bytes in ” + response.RoundtripTime.ToString() + ” ms.” + “\n”);
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s