curl timeout less than 1000ms always fails?

后端 未结 2 1833
萌比男神i
萌比男神i 2020-12-11 03:41

This code always fails (i.e., $result is Boolean false):

     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $path);
     cu         


        
相关标签:
2条回答
  • 2020-12-11 04:12

    Another way of dealing with this would be to set the CURLOPT_NOSIGNAL option to 1 in addition to the CURLOPT_CONNECTTIMEOUT_MS. See http://curl.haxx.se/libcurl/c/CURLOPT_NOSIGNAL.html for more info.

    0 讨论(0)
  • 2020-12-11 04:21

    from: http://www.php.net/manual/en/function.curl-setopt.php

    The number of milliseconds to wait while trying to connect. Use 0 to wait indefinitely. 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.

    0 讨论(0)
提交回复
热议问题