private bool InternetIsConnected
{
get
{
bool ret = false;
try
{
string HostName = Dns.GetHostName();
if (HostName.StartsWith("Pocket"))
{
IPHostEntry thisHost = Dns.GetHostEntry(HostName);
string thisIpAddr = thisHost.AddressList[0].ToString();
ret = thisIpAddr != IPAddress.Parse("127.0.0.1").ToString();
// If true then the emulator is on the cradle/network so check for internet
if (ret)
{
HostName = "yourwebsite.com"; ///use a known wwebsite
thisHost = Dns.GetHostEntry(HostName);
thisIpAddr = thisHost.AddressList[0].ToString();
ret = thisIpAddr == IPAddress.Parse("xxx.xxx.xxx.xxx").ToString(); //use known IPaddress
}
}
else //Looks like this is a live device
{
ret = true;
}
}
catch
{
lInternetStatus.Text = "Internet offline";
return false;
}
if (ret)
{
lInternetStatus.Text = "Internet connected";
}
lInternetStatus.Refresh();
return (this.OnLine = ret);
}
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.