2010-11-19 7 views

答えて

0

あなたがWindows上で実行している場合は、curl_multi使用することができます。

// create cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, "http://domain/path/to/script"); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

//create the multiple cURL handle 
$mh = curl_multi_init(); 

//add the handle 
curl_multi_add_handle($mh,$ch); 

// execute the handle 
curl_multi_exec($mh,$running); 

をしかし、あなたはLinuxを実行している場合、あなたはあまりにもフォークがあります

$pid = pcntl_fork(); 
if ($pid == -1) { 
    die('could not fork'); 
} else if ($pid) { // mother process 
    // continue doing stuff here 
    echo 'Child labor '; 
    echo 'is acceptable '; 
    echo 'in programming'; 

    // wait for the child to finish 
    pcntl_wait($status); 
} else { // child process 
    // do big loop here 
    while (...) { 
     sleep(1000); 
    } 
} 
+0

スクリプトがために動作しますループ内の時間、このカールはループをトリガーして終了しますか?私は接続が1秒以上確立されることを望んでいません。 –

+0

呼び出しスクリプト(高速実行スクリプト)が終了する前にカールが切断されません。しかし、curlが接続を閉じると、呼び出されたスクリプト(遅いもの)がApacheによって殺される可能性があります。 –

+1

set_time_limitがゼロに設定され、ignore_user_abortがtrueに設定されている場合は実際にはありません –

関連する問題