PHP forked process referring to parent process variables
Posted on 2003-11-11
I have written a multi-thread (process) socket server script. It consists of a Listener class (one process) and XMLSocket class (separate client processes). The problem is that I cannot refer from the XMLSocket process back to the Listener process the socket array or any of its variables. Once the Listener spawns a new child/connection, the Listener class variables can be passed on to the XMLSocket class as 'copy' only but not by reference. Hence the spawned children/connection will not know of any later changes in the Listener client array or any of the Listener's variable but only the 'status' of the Listener at the time of the process is forked. I would need to have the spawned connections refer back to the parent process variables since I may use this as a chat server, hence each child has to be able to refer to the 'parent' list of spawned connections for communication.
I guess this is the difference between multi-thread and mutli-process. However, I would like to know if there is a way to work around this problem. Answers telling me to use other programming languages are not accepted. The scope of this question covers PHP only.