On Fri, Jul 7, 2017 at 11:04 AM, Martijn van Duren <p...@list.imperialat.at> wrote: > On 07/07/17 16:38, Sara Golemon wrote: > Yes, although tcp/ip are also possible with stream_socket_pair. > nit; socket_pair sockets are not AF_INET, they're just sockets.
> The point is, regardless of unix - or tcp sockets, they still have an > underlying file descriptor, which I need to specify to the child, so > that they can start using it. Ergo, I need to find a way to export this > from the stream into PHP. > You misunderstand, I'm not saying to create a unix socket and try to pass that open pair to the child. I'm saying listen on a unix domain socket on the file system and tell the children what the path is. They can all individually then open streams to the parent using the path. Psuedo code: // parent $mysocket = 'unix://tmp/parent.sock'; $server = stream_socket_server($mysocket); spawn_child('child_proc --sock='.escapeshellarg($mysocket)); $child = stream_socket_accept($server); var_dump(fgets($child)); // string (8) "Hi mom!\n" // child $parentssocket = parseCliArg('sock'); $stream = stream_socket_client($parentssocket); fwrite($stream, "Hi mom!\n"); Then the children can each report their own listening sockets to the parent and the parent can provide a lookup for siblings to find each other and allow them to open sockets to each other. Trying to pass a meaningless number to the child that it can't do anything with isn't going to work. -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php