Hi,
I have a doubt. I need to know whether internet connection is
present in the device or not.
I tried 'InternetGetConnectedState' but I find it only says
whether my system is configured
for it or not.

Some help. regards,

Arun.

Re: internet connection present. by ctacke/>

ctacke/>
Thu Jun 22 08:46:39 CDT 2006

Try resolving a reote address or pinging a known server.

-Chris

"arunmib" <kumarpam@gmail.com> wrote in message
news:1150979991.024610.171200@r2g2000cwb.googlegroups.com...
> Hi,
> I have a doubt. I need to know whether internet connection is
> present in the device or not.
> I tried 'InternetGetConnectedState' but I find it only says
> whether my system is configured
> for it or not.
>
> Some help. regards,
>
> Arun.
>



RE: internet connection present. by Mike

Mike
Thu Jun 22 14:13:01 CDT 2006

Try this code:

using System.Net;

internal static void TestConnection()
{
// Get IP-Address-Information
string HostName = Dns.GetHostName();
IPHostEntry HostIP = Dns.GetHostEntry(HostName);

string HostIPAddress = HostIP.AddressList[0].ToString();

//If the device is set to loopback, no network connection exists
if (HostIPAddress == IPAddress.Parse("127.0.0.1").ToString())
{
MessageBox.Show("There is no network connection.");
return;
}

// Now we use a simple Web Request/Response to test for
connectivity
// to the WebService
Cursor.Current = Cursors.WaitCursor;
try
{
WebResponse resp = null;
WebRequest req =
WebRequest.Create("http://www.wochners-institut.de");
req.Timeout = 10000;
resp = req.GetResponse();

MessageBox.Show("Internet is there...!");

}
catch (Exception ex)
{
MessageBox.Show("There is network connection, but the
website is not reachable...\n" + ex.Message);
}
finally
{
Cursor.Current = Cursors.Default;
}
}


"arunmib" wrote:

> Hi,
> I have a doubt. I need to know whether internet connection is
> present in the device or not.
> I tried 'InternetGetConnectedState' but I find it only says
> whether my system is configured
> for it or not.
>
> Some help. regards,
>
> Arun.
>
>