title: PHP cURL timeout ignored
body: <p>Using <code>curl_setopt()</code> I have set <code>CURLOPT_CONNECTTIMEOUT_MS</code> to 1000 (1 second) and have set up <strong>another script</strong> that sleeps for 5 seconds, then responds 200 OK (using <code>sleep()</code>) which I call for testing purposes. My script always waits for the response, even though it should yield in a cURL timeout error.</p>
  
  <p>How do I make the timeout work as expected and interrupt the request?</p>
  
  <pre><code>$ch = curl_init($url);
  curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER =&gt; TRUE,
    CURLOPT_FOLLOWLOCATION =&gt; TRUE,
    CURLOPT_NOBODY =&gt; TRUE,
    CURLOPT_PROTOCOLS =&gt; CURLPROTO_HTTP | CURLPROTO_HTTPS,
    CURLOPT_CONNECTTIMEOUT_MS =&gt; 1000,
    CURLOPT_MAXREDIRS =&gt; 5,
    CURLOPT_USERAGENT =&gt; 'Linkit/2.x Drupal/7.x',
  ));
  $document = curl_exec($ch);
  </code></pre>
  
  <p>I have also tried <code>CURLOPT_TIMEOUT_MS</code> and also the variants without the <code>_MS</code> suffixes.</p>
  
  <p>I'm using PHP 5.3.4 with cURL 7.19.7 on OS X 10.6, XAMPP.</p>