Re: PHP Multi-threading
- From: George Maicovschi <georgemaicovschi@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 07:21:58 -0700 (PDT)
On Mar 31, 5:45 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
George Maicovschi wrote:
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.
Where are you creating new threads?
I agree with Erwin - if you need to use threads, PHP isn't a good way to
go. If you really need this and it's has to be in PHP, I'd look at
spawning multiple processes off and do the work in batch mode, perhaps
saving the results in a database.
But personally I'd be looking at another language such as Java or C/C++
which has good thread support.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================
Yeah, I would go the C way myself, but it has to be PHP...
.
- 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
- Re: PHP Multi-threading
- From: George Maicovschi
- Re: PHP Multi-threading
- From: Jerry Stuckle
- PHP Multi-threading
- Prev by Date: Re: web crawling program
- Next by Date: Re: question about select tag in php
- Previous by thread: Re: PHP Multi-threading
- Next by thread: Re: PHP Multi-threading
- Index(es):
Relevant Pages
- Re: Recommended Windows Hosts
... BTW...how come PHP sites always have that similar cool "look" about them? ...
| | I have all of my clients paying directly for their hosting. ... | | FrontPage Resources,
WebCircle, MS KB Quick Links, etc. ... | | | recommendations for WINDOWS Hosts. ...
(microsoft.public.frontpage.client) - Re: PHP Multi-threading
... George Maicovschi wrote: ... action on lets say 100 different hosts in
the same time. ... multi-threading ar a way to emulate it. ... Basically that's
my approach to multi-threading emulation in PHP. ... (comp.lang.php) - Re: PHP Multi-threading
... action on lets say 100 different hosts in the same time. ... multi-threading
ar a way to emulate it. ... So now the threading part is emulated through Apache,
... Basically that's my approach to multi-threading emulation in PHP. ... (comp.lang.php) - Re: PHP security (or the lack thereof)
... But in the 1990s, Java was created. ... That PHP is relatively new with
respect to computing ... PHP-CGI: .28 million hosts ... average "experience level"
of each developer is equal, ... (Bugtraq) - Apache2/PHP permissions in ISP environment
... we are running debian sarge for a virtual hosting box. ... We are running
name based virtual hosting for all hosts except SSL hosts ... So, when PHP creates
a file 'test.txt', a script ... (Debian-User)