From: Tontonq Tontonq on
Hi
how to make a script multi task based like this

<?


for($i=1;$i<=100;$i++)
{


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.facebook.com/ajax/reqs.php?__a=1'
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; tr)
Presto/2.6.22 Version/10.50");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com/reqs.php");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:8888");
curl_exec($ch);


}
?>


lets say this takes 1000 seconds and it doesnt focus to another curl process
before it finish the previous one

is it possible to let the script focus another curl process without wait
answer of the previous one

i hope if u could understand me ^^
From: "Alex Major" on
> -----Original Message-----
> From: Tontonq Tontonq [mailto:rootdot(a)gmail.com]
> Sent: 04 August 2010 18:21
> To: PHP General Mailing List
> Subject: [PHP] multi thread work?
>
> Hi
> how to make a script multi task based like this
>
> <?
>
>
> for($i=1;$i<=100;$i++)
> {
>
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL,
> 'http://www.facebook.com/ajax/reqs.php?__a=1'
> );
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; tr)
> Presto/2.6.22 Version/10.50");
> curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
> curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com/reqs.php");
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
> curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:8888");
> curl_exec($ch);
>
>
> }
> ?>
>
>
> lets say this takes 1000 seconds and it doesnt focus to another curl
> process
> before it finish the previous one
>
> is it possible to let the script focus another curl process without
> wait
> answer of the previous one
>
> i hope if u could understand me ^^

This question has been asked several times over the last week, have a look
over the archive ;).

You need to be looking at something like process forking (
http://php.net/manual/en/function.pcntl-fork.php ).

Alex.

From: Rasmus Lerdorf on
On 8/4/10 10:27 AM, Alex Major wrote:
>> -----Original Message-----
>> From: Tontonq Tontonq [mailto:rootdot(a)gmail.com]
>> Sent: 04 August 2010 18:21
>> To: PHP General Mailing List
>> Subject: [PHP] multi thread work?
>>
>> Hi
>> how to make a script multi task based like this
>>
>> <?
>>
>>
>> for($i=1;$i<=100;$i++)
>> {
>>
>>
>> $ch = curl_init();
>> curl_setopt($ch, CURLOPT_URL,
>> 'http://www.facebook.com/ajax/reqs.php?__a=1'
>> );
>> curl_setopt($ch, CURLOPT_POST, 1);
>> curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; tr)
>> Presto/2.6.22 Version/10.50");
>> curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
>> curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com/reqs.php");
>> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>> //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
>> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
>> curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:8888");
>> curl_exec($ch);
>>
>>
>> }
>> ?>
>>
>>
>> lets say this takes 1000 seconds and it doesnt focus to another curl
>> process
>> before it finish the previous one
>>
>> is it possible to let the script focus another curl process without
>> wait
>> answer of the previous one
>>
>> i hope if u could understand me ^^
>
> This question has been asked several times over the last week, have a look
> over the archive ;).
>
> You need to be looking at something like process forking (
> http://php.net/manual/en/function.pcntl-fork.php ).

Definitely not. You should be looking either at curl_multi or at
something like Gearman. pcntl is very similar to eval for Web apps. If
you find yourself using them, you know you have taken a wrong turn
somewhere.

-Rasmus
From: Daniel Brown on
On Wed, Aug 4, 2010 at 13:21, Tontonq Tontonq <rootdot(a)gmail.com> wrote:
> Hi
> how to make a script multi task  based like this
[snip=code]
>
> lets say this takes 1000 seconds and it doesnt focus to another curl process
> before it finish the previous one
>
> is it possible to let the script focus another curl process without wait
> answer of the previous one

Might want to check into Gearman for this one.

http://gearman.org/

--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown(a)parasane.net || danbrown(a)php.net
http://www.parasane.net/ || http://www.pilotpig.net/