title: Check network connection in both Windows ce (PDA) and Desktop
body: <p>I am developing a PDA Application using c#,i need's to check internet connection before application starts execute,i have used the following code,which is working fine PDA system but not in Desktop</p>
  
  <pre><code>public static bool CheckForInternetConnection()
      {
          try
          {
              string hosname = System.Net.Dns.GetHostName();
              IPHostEntry ent = Dns.GetHostEntry(hosname);
              string ip = ent.AddressList[0].ToString();
              bool ret = (ip != "127.0.0.1" &amp;&amp; ip != "::1");
              //MessageBox.Show(ret.ToString());
              if (ret)
              {
                  // MessageBox.Show("internet connected");
              }
              else
              {
                  MessageBox.Show("internet not connected");
  
              }
              return ret;
          }
          catch
          {
              MessageBox.Show("internet not connected catch");
              return false;
          }
      }
  </code></pre>
  
  <p>when I try to execute the same exe in desktop which is throwing me "internet not connected",where i am going wrong?</p>