changing a few options and deleting other resources can not I use the same multi handle:
$ch1 = curl_init(); $ch2 = curl_init(); $ch3 = curl_init(); curl_setopt($ch1, CURLOPT_URL, "http://mytestsite.com/test.curl.php?test=a"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch2, CURLOPT_URL, "http://mytestsite.com/test.curl.php?test=b"); curl_setopt($ch2, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch3, CURLOPT_URL, "http://mytestsite.com/test.curl.php?test=b"); curl_setopt($ch3, CURLOPT_HEADER, 0); curl_setopt($ch3, CURLOPT_RETURNTRANSFER, TRUE); $mh = curl_multi_init(); curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); curl_multi_add_handle($mh,$ch3); $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) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } $test1 = curl_multi_getcontent( $ch1 ); $test2 = curl_multi_getcontent( $ch2 ); $test3 = curl_multi_getcontent( $ch3 ); error_log($test1); // a error_log($test2); // b error_log($test3); // b curl_multi_remove_handle($mh, $ch1); // curl_multi_remove_handle($mh, $ch2); // curl_multi_remove_handle($mh, $ch3); curl_setopt($ch2, CURLOPT_URL, "http://mytestsite.com/test.curl.php?test=c"); curl_setopt($ch3, CURLOPT_URL, "http://mytestsite.com/test.curl.php?test=c"); $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) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } $test1 = curl_multi_getcontent( $ch1 ); $test2 = curl_multi_getcontent( $ch2 ); $test3 = curl_multi_getcontent( $ch3 ); error_log($test1); // a error_log($test2); // b error_log($test3); // b curl_multi_close($mh);
i see:
a b b a b b
i want to see:
a b b a c c
After a transfer, you just set new options in the handle and make another transfer. This will make libcurl to re-use the same connection if it can.
can help me?
thanks