Advertisement
retesere20

curl-multi approaches

Oct 26th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Approach #1
  2.  
  3. // While we're still active, execute curl
  4. $active = null;
  5. do {
  6. $mrc = curl_multi_exec($multi, $active);
  7. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  8.  
  9. while ($active && $mrc == CURLM_OK) {
  10. // Wait for activity on any curl-connection
  11. if (curl_multi_select($multi) == -1) {
  12. continue;
  13. }
  14. // Continue to exec until curl is ready to give us more data
  15. do {
  16. $mrc = curl_multi_exec($multi, $active);
  17. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. Approach #2
  25.  
  26. //$running = null;
  27. //do {
  28. // curl_multi_exec($mh, $running);
  29. //} while ($running);
  30.  
  31. do {
  32. $status = curl_multi_exec($mh, $active);
  33.  
  34. if ($active) {
  35. curl_multi_select($mh);
  36. }
  37. }
  38. //while ($active && $status == CURLM_OK);
  39. while ($active && $mrc == CURLM_OK) {
  40. if (curl_multi_select($mh) == -1) {
  41. usleep(100); continue;
  42. }
  43. do {
  44. $mrc = curl_multi_exec($mh, $active);
  45. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement