tags:

views:

637

answers:

1

I am using curl to call a web service API. The service can unresponsive so I want to set a timeout. When I use CURLOPT_TIMEOUT things work as expected. But when I use CURLOPT_TIMEOUT_MS (note the 'MS' for milliseconds) the timeout doesn't appear to kick in at all. php.net tells me that the latter was available since PHP version 5.2.3, and I am using 5.2.6.

Any ideas why this is happening?

Thanks.

Code fragment:

$c = curl_init();
curl_setopt( $c, CURLOPT_URL, $call );
curl_setopt( $c, CURLOPT_HTTPHEADER, $headers); 
curl_setopt( $c, CURLOPT_HEADER, false );
curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $c, CURLOPT_TIMEOUT_MS, 100 ); 
curl_setopt( $c, CURLOPT_CONNECTIONTIMEOUT_MS, 100 ); 
$result = curl_exec($c);
curl_close($c);
+1  A: 

To close this question:

The version of curl I am using (7.15.5) doesn't support CURLOPT_TIMEOUT_MS. According to Greg I need at least 7.16.2.

Greg
And not just according to Greg, see: http://www.php.net/manual/en/function.curl-setopt.php
James Murty