I want my PPC app to be "network aware". Question is in two parts
1. How can i determine if the PPC in on a network?
2. How can i be alerted automatically, when network is detected?
Any ideas?
Jeppe Jespersen
Denmark
1. If you want to check if the PDA has network connectivity:
public static bool HasNetworkConnectivity()
// Call this class as follows: bool bResponse =
Net.IsWebAccessible;
{
HttpWebRequest hwrRequest;
HttpWebResponse hwrResponse;
string strUrl = @"http://www.microsoft.com/";
bool bConnected = false;
try
{
hwrRequest = (HttpWebRequest)WebRequest.Create(strUrl);
hwrResponse =
(HttpWebResponse)hwrRequest.GetResponse();
if (hwrResponse.StatusCode == HttpStatusCode.OK)
{
bConnected = true;
}
hwrResponse.GetResponseStream().Close();
}
catch (WebException we)
{
bConnected = false;
}
catch (Exception ex)
{
bConnected = false;
}
finally
{
hwrRequest = null;
hwrResponse = null;
}
return bConnected;
}
Take also a look at ConnectionManager from OpenNETCF. I think it gives
you the ability to enumerate all connections of the device. If you need
that, tell me so that I can show you some code.
Hope it helps.
Regards.
Paul G. Tobey [eMVP] - 10 Jan 2006 16:34 GMT
I believe that the OpenNetCF.Net namespace also has the ability to tell you
when there's a change in the connectivity state of an Adapter. As you might
imagine, "how do I tell if there's a network connection is asked almost
daily". Do a search of the archives using GoogleGroups and read...
http://groups.google.com/group/microsoft.public.dotnet.framework.compactframewor
k?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8
Paul T.
> 1. If you want to check if the PDA has network connectivity:
>
[quoted text clipped - 40 lines]
>
> Regards.