title: Connection.open for hangs indefinitely, no exception is thrown
body: <p>When I try to do the following code, the program hangs indefinitely. I don't know why and there seems to be other unanswered topics on the matter. Although, if the IP\website cannot be reached, then it works as intended.</p>
  
  <pre class="lang-cs prettyprint-override"><code>    private void DoStuff()
      {
          string connectionString = "Data Source=www.google.com;Connection Timeout=5";
          using (SqlConnection connection = new SqlConnection(connectionString))
          {
              connection.Open(); //Hangs here indefinitely
              Console.WriteLine("Test");
          }
      }
  </code></pre>
  
  <p>For example, if I set the connection string to </p>
  
  <p><code>connectionString = "Data Source=www.nonexistentsite.com;Connection Timeout=5";</code></p>
  
  <p>then it will throw an exception. How do I get it to throw an exception for an active site? ... Also <strong><em>google</em></strong> is just for testing purposes, obviously.</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>If I try to connect to an unreachable server name or IP address I <strong>WILL</strong> get this exception...</p>
  
  <p><code>A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</code></p>
  
  <p><strong>UPDATE :</strong></p>
  
  <p>After letting the program run for quite a while, it usually times out finally after 3-5 minutes and gives me the error I posted above. How can I get it to timeout quicker?</p>