Re: PHP Multi-threading
- From: George Maicovschi <georgemaicovschi@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 06:24:37 -0700 (PDT)
Hey Erwin,
It's just an experiment of mine, nothing production-related... YET :-)
The thing goes like this. I have a script that's supposed to do an
action on lets say 100 different hosts in the same time. So I need
multi-threading ar a way to emulate it. My approach was this:
$threads=array();
$responses=array();
foreach ($hosts as $host)
$threads=fopen('http://domain.with.the.script/path/to/script/
script.php?op=action&host={$host}','r');
foreach ($threads as $thread_id=>$thread)
if ($thread)
{
$responses[$thread_id]=''
while (!feof($thread))
$response[$thread_id].=fgets($thread);
fclose($thread);
}
So now the threading part is emulated through Apache, making
concurrent requests to the script.php that contains the actions to be
undertaken and specifying the host that I want to be the target of the
actions.
Basically that's my approach to multi-threading emulation in PHP.
So...any suggestions/ideas/anything? :-)
I am really curious about other approaches because this multi-
threading thing in PHP seems rather disturbing because of it's
absence. :-)
Cheers,
George Maicovschi.
.
- Follow-Ups:
- Re: PHP Multi-threading
- From: Jerry Stuckle
- Re: PHP Multi-threading
- References:
- PHP Multi-threading
- From: George Maicovschi
- Re: PHP Multi-threading
- From: Erwin Moller
- PHP Multi-threading
- Prev by Date: Re: Spam on the increase?
- Next by Date: web crawling program
- Previous by thread: Re: PHP Multi-threading
- Next by thread: Re: PHP Multi-threading
- Index(es):
Relevant Pages
|
|