i have used the following code to check for internet connection it works perfectly without firewall & proxy. how do i check net connection in firewall & proxy mode. please help me
private static ManualResetEvent connectDone = new ManualResetEvent(false);
public static bool IsInternetConnected()
{
int Desc;
string[] sitesList = { "www.google.co.in", "www.microsoft.com", "www.sun.com" };
bool status;
status = InternetGetConnectedState(out Desc, 0);
if (status)
{
try
{
connectDone.Reset();
TcpClient client = new TcpClient();
client.BeginConnect(sitesList[0], 80, new AsyncCallback(ConnectCallback), client);
connectDone.WaitOne(1000, false);
if (client.Connected)
status = true;
else
status = false;
client.Close();
}
catch (System.Exception ex)
{
BringDebug.WriteToLog("BringNet", "IsInternetConnected", ex.Message);
return false;
}
}
else
{
return false;
}
return status;
}
private static void ConnectCallback(IAsyncResult ar)
{
try
{
TcpClient client1 = (TcpClient)ar.AsyncState;
client1.EndConnect(ar); // Complete the connection.
connectDone.Set(); // trigger the connectDone event
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}