Search This Blog

Saturday, July 11, 2009

Detect an Internet Connection

Simple Code to make sure there is an active internet connection.
 using System.Net.Sockets;

private bool ConnectionExists()
{
try
{
TcpClient clnt = new TcpClient("www.google.com", 80);
clnt.Close();
return true;
}
catch (System.Exception)
{
return false;
}
}

No comments: