Forum Moderators: coopster

Message Too Old, No Replies

Explain the following php line of code?

while(($execrun = curl_multi_exec...

         

rollinj

8:03 pm on Jan 12, 2010 (gmt 0)

10+ Year Member



while(($execrun = curl_multi_exec($master, $running)) == CURLM_CALL_MULTI_PERFORM) sleep(1);

If you could spell out exactly what that code does in english/pseudo-code for me please, I will love you long time.

ticktock

8:27 pm on Jan 12, 2010 (gmt 0)

10+ Year Member



are you familiar with Visual Basic? - it's like a "DoEvents"

Here:
[php.net...]

I found Found this good explanation from viczbk.ru about CURLM_CALL_MULTI_PERFORM:
"When you've added the handles you have for the moment (you can still add new ones at any time), you start the transfers by call curl_multi_perform(3).

curl_multi_perform(3) is asynchronous. It will only execute as little as possible and then return back control to your program. It is designed to never block. If it returns CURLM_CALL_MULTI_PERFORM you better call it again soon, as that is a signal that it still has local data to send or remote data to receive."

Notice, curl_multi_perform vs curl_multi_exec - the first allows asynchronous IO, curl_multi_exec does not. The while loop you have may be expecting curl_multi_exec to allow asynchronous IO when it does not.

I'm not 100% sure of the loop intentions without knowing what handles it will execute.

rollinj

11:12 am on Jan 13, 2010 (gmt 0)

10+ Year Member



re: "If it returns CURLM_CALL_MULTI_PERFORM you better call it again soon"

So I take it that sleep(1) is of no value to my above code? Only a hindrance?

StoutFiles

12:48 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sleep(1) delays the program for a second. Considering this is what the while loop is for, I assume it's important in some way.