title: C# Testing active internet connection. Pinging google.com
body: <p>C# 2008</p>
  
  <p>I am using this code to test for an internet connection. As my application will have to login to a web server. However, if the user internet connection was to fail or cable pulled out. I will have to notify the user.</p>
  
  <pre><code> // Ping www.google.com to check if the user has a internet connection.
      public bool PingTest()
      {
          Ping ping = new Ping();
  
          PingReply pingStatus = ping.Send(IPAddress.Parse("208.69.34.231"));
  
          if (pingStatus.Status == IPStatus.Success)
          {
              return true;
          }
          else
          {
              return false;
          }
      }
  </code></pre>
  
  <p>The only way I think I can test for an Internet connection is to ping www.google.com. So I have a used a server timer which I have set for 500 milliseconds and in the lapsed event it will call this ping function. If the ping returns false. Then my app will take appropriate action.</p>
  
  <p>Do you think using google as a way to test an Internet connect is a good thing. If google was to fail, then my app would not function. Is polling 1/2 second to much or too little? Just wondering about my whole idea if it is good or not?</p>
  
  <p>Many thanks,</p>