strange comporting of CURL library

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

strange comporting of CURL library

Post by ddragas »

Hi all

I've got strange comporting of CURL library.
I've got 2 servers witch are hosting 2 sites.

If I "fire" (with curl script below) from first server, php script that is on second server it "fires" back php script on first server, and that is ok and ment to be like this.

problem is that it goes in endless loop. It will never stop.

And If I run this script in browser it runs only once (like it should)

Is it something wrong with my CURL script below?

Code: Select all

 
 
$path = array('first/path/to/thefile/', 'second/path/to/thefile/', ......);
            for($r = 0; $r<= count($path); $r++)
                {
                    $ch[] = $r; 
                }
            
            for($chInit = 0; $chInit<count($ch); $chInit++)
                {
                    $ch[$chInit] = curl_init();
                    curl_setopt($ch[$chInit], CURLOPT_URL, $path[$chInit]);
                }
            
            $mh = curl_multi_init();
            
            for($chMH = 0; $chMH<count($ch); $chMH++)
                {
                    curl_multi_add_handle($mh,$ch[$chMH]);      
                }
            
            $running=null;
            
            do  {
                    curl_multi_exec($mh,$running);
                } 
                while ($running > 0);
            
            for($chMH1 = 0; $chMH1<count($ch); $chMH1++)
                {
                    curl_multi_remove_handle($mh,$ch[$chMH1]);
                }
            curl_multi_close($mh);  
 
Post Reply