I use curl to call the web service API. The service may not respond, so I want to set a timeout. When I use CURLOPT_TIMEOUT everything works as expected. But when I use CURLOPT_TIMEOUT_MS (note the "MS" in milliseconds), the timeout does not appear at all. php.net tells me that the latter was available with PHP version 5.2.3, and I am using 5.2.6.
Any ideas why this is happening?
Thanks.
Code snippet:
$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);
source share