title: Adjusting HttpWebRequest Connection Timeout in C#
body: <p><em>I believe after lengthy research and searching, I have discovered that what I want to do is probably better served by setting up an asynchronous connection and terminating it after the desired timeout... But I will go ahead and ask anyway!</em></p>
  
  <p>Quick snippet of code:</p>
  
  <pre><code>HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create(url);
  webReq.Timeout = 5000;
  HttpWebResponse response = (HttpWebResponse)webReq.GetResponse(); 
  // this takes ~20+ sec on servers that aren't on the proper port, etc.
  </code></pre>
  
  <p>I have an <code>HttpWebRequest</code> method that is in a multi-threaded application, in which I am connecting to a large number of company web servers. In cases where the server is not responding, the <code>HttpWebRequest.GetResponse()</code> is taking about 20 seconds to time out, even though I have specified a timeout of only 5 seconds. In the interest of getting through the servers on a regular interval, I want to skip those taking longer than 5 seconds to connect to.</p>
  
  <p>So the question is: <em>"Is there a simple way to specify/decrease a connection timeout for a WebRequest or HttpWebRequest?"</em></p>