Have a look at zeromq.


Hope it helps.

On Fri, Jan 20, 2012 at 12:24 AM, Thomas Johnson <t...@claimlynx.com> wrote:

> Hello,
> PHP noob here. I've been working on writing a script (command-line) that
> forks a number of children to do various tasks. I've been using
> pcntl_waitpid inside a loop to wait for the children to exit, act on the
> results, and fork another copy of the child. Where I seem to be running
> into trouble is in managing communication between child and parent, so that
> the parent has an indication of result inside the child.
> In the past, I've done this in Perl using something along the lines of:
> open(FILEHANDLE,"-|");
> In Perl, this has the effect of forking the process and attaching the
> STDOUT of the child to FILEHANDLE on the parent. Thus, when the child
> exits, I read FILEHANDLE to get the output from the child.
> Is there a similar way of achieving a similar result in PHP? Am I crazy? So
> far, I have tried to communicate between the processes using sockets
> (socket_create_pair). However, this seems to be a dead-end, I get a
> "connection reset by peer" when I try to socket_read() from the parent. I
> assume this is because the socket is closed by the exit of the child.
> Any insight or criticism is appreciated.
> --
> Thomas Johnson
> ClaimLynx, Inc. <952-593-5969%20x2302>

Reply via email to