curl的timeout 崩溃问题

最近供一个服务用到了curl,发现一件奇怪的事。
curl的超时如果设置<1000ms的话有可能会返回失效甚至崩溃...
到网上查了一下原因:
CURLOPT_TIMEOUT_MS
The maximum number of milliseconds to allow cURL functions to execute. If libcurl is built to use the standard system name resolver, that portion of the connect will still use full-second resolution for timeouts with a minimum timeout allowed of one second. 
官方文档上说curl的超时只支持秒级,因为curl底层的select()调用超时位1000ms。

如果要完成毫秒级的超时,可以使用curl_multi_select()。或者修改原代码。可以参见一个同行的连接:
http://hi.baidu.com/tarotme/blog/item/07bdaefb6921c4284f4aeaec.html

你可能感兴趣的:(timeout,curl,1000ms,curlopt)