curl_multi_select总是在PHP 5.5上返回-1

时间:2015-06-29 08:54:51

标签: php curl

我在Windows和Linux上检查了我的许多php安装版本5.5 curl_multi_select总是返回-1, 我也尝试过睡觉,但它总是返回-1

需要哪些配置才能解决此问题?

$ch1 = curl_init();
$ch2 = curl_init();

curl_setopt($ch1, CURLOPT_URL, "http://yahoo.com");
curl_setopt($ch1, CURLOPT_CONNECT_ONLY, 1);
curl_setopt($ch2, CURLOPT_URL, "http://google.com.pk");
curl_setopt($ch2, CURLOPT_HEADER, 0);

$mh = curl_multi_init();
curl_multi_setopt ( $mh,CURLMOPT_PIPELINING,1);
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        while(($info = curl_multi_info_read($mh)) !== false){
            if ($info["result"] == CURLE_OK){
                $content = curl_multi_getcontent($info["handle"]);
                echo "<Br>Result : " . $content . "<Br>";
            }
        }       
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
    else {
        usleep(100000);
    }
}
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

0 个答案:

没有答案