Hey dear stackoverflow members,
I have set up a small script to use the known cUrl feature of curl_multi_* code to provide asynchronous non-blocking requests , this is a rough version of the code:
$mch = curl_multi_init();
$ch = curl_init();
url_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_multi_add_handle($mch ,$ch);
$running = null;
do {
curl_multi_exec($mch ,$running);
} while($running > 0);
curl_multi_remove_handle($mch,$ch);
curl_close($ch);
basically this is used to send one request as a parallel request to allow the code to keep running while another script is called via cURL , I do not care for the result therefore I used no code to handle it I just want the other script to be called while the code after the curl call will keep running.
first of all I don't understand why do I need the while loop , wouldn't calling multi_exec once for one request work ? since not using the loop does not run the script on the $url(I checked).
secondly and my biggest problem , this should be asynchronous , I tried putting sleep(10) on the other script and the calling script waits 10 seconds before continuing , I dont get it this should be non-blocking and should keep running.
what am I doing wrong?