Re[2]: [PHP-DEV] PHP and Threads
| From: | Daniel Lorch | Date: | Mon, 22 Apr 2002 16:11:24 +0000 |
| Subject: | Re[2]: [PHP-DEV] PHP and Threads | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-83143@lists.php.net to get a copy of this message | ||
Hi,
first of all, thanks for the bugfix. it will go into phpserv 0.02
along with a sf.net account, seperate mailinglists (to not bother php-dev
anymore :))
> Thanks Daniel for your excellent input. I have managed to create a forking
> socket handler, although I am now approched by a new issue. How do I get
> the sockets to communication to each other?
The question should be, how you get the _processes_ to communicate to
each other. Als already mentioned by Steve Meyers, you could use the
signals reserved for user space: SIGUSR1 and SIGUSR2. You can send
them to another process by using posix_kill: http://php.net/posix_kill
posix_kill($pid, SIGUSR1);
unfortunately these signals provide only limited functionality.
Another approach to IPC (inter process communication) are named pipes.
I suggest you to have a look at "Beej's Guide to Unix Interprocess
Communication", which provides an excellent hands-on introduction on
this topic:
http://www.ecst.csuchico.edu/~beej/guide/
"Beej's Guide to Network Programming" ist worth reading, too :)
> I can process and parse the input from the children individually but when
> upon a certain command being sent by child 1, I want *all* the children to
> be issued a command.
you'd have to broadcast them to all child processes. I would use a
child --[request]--> parent
parent --> child 1 \
--> child 2 |- broadcast
--> child n /
... approach. Unfortunately my knowledge on this topic is limited.
Maybe there is someone more savvy on this list :)
-daniel