Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99811 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96145 invoked from network); 7 Jul 2017 16:03:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jul 2017 16:03:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.128.181 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.128.181 mail-wr0-f181.google.com Received: from [209.85.128.181] ([209.85.128.181:36353] helo=mail-wr0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/D2-47109-FD0BF595 for ; Fri, 07 Jul 2017 12:03:44 -0400 Received: by mail-wr0-f181.google.com with SMTP id c11so52914884wrc.3 for ; Fri, 07 Jul 2017 09:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=tASyqBtrkmlBe8mXmCjzXi9PNp1jZS5JM5bXfvmB5p4=; b=UOxsUOQD51bUKEHBMJUEHqLF2vjBnpTbHUPrl8++palqxSIKS6wMTjkcmxf4pk0SJc jb2xddcM3J+PrCZteQeOF1hVZYSnHXef/maibXKw4tPvem06hDhetEMupEm5l+Jk9AXA TDCkKfTk4ZNChZ7vZS51N1EhiVezUgDaSczc7hz6109n/80nMfO1R9vkzHbIEr7HJFmO 54nSFJW5YaUW7fouEMkxoDe+UPsaGy/hTBbU08CyodXoIDyZcPUxXL6cWkEWFkZePFdy dg5+YZNn17MHTmfuYQTyTSWiJWCutI5OSf7lpPQ1OUVthoQDqs14KNWoxlW8M1NbeZHM uoGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=tASyqBtrkmlBe8mXmCjzXi9PNp1jZS5JM5bXfvmB5p4=; b=LipN5PF81vu3UaVPRdGTuj19bwHpqdUp6911CnkbCmAR0JNweWi0AiOdnbZ0ckjGrH 3Jcoiyf9/mPv9hhfVd02mMy/IsYzHoXM2eGKwzIZ0jHzrm+p8XDK7B03eckq7z5ZtJ/d nxoylTrcJOwkolwC334GdLSS1aouJ/TZZ7lxcaTeSQJ1KC24ufdobUhmXeZ1YzN+y/V4 wwhV069+7jlxN6nEdi5mD1ugNjK3bdRf+almiAGRo2IN6dwCOouL81DCxmPC7HK9W0+0 ZWijK5QcmesB2i9yMgY86ITLuI3N9pbSaRG0cewcoB1pQK/mmNIp/XS3zJ8hcePBVZ9q 6aag== X-Gm-Message-State: AIVw113feX8WhQkjpZJkYii94S+2/tZO/X7LvrPrtPDToWmAcyXIeu1S EbEMlJ3TX6Gv8JrLcqITH5nIKsYmyz+S X-Received: by 10.28.11.134 with SMTP id 128mr2854264wml.79.1499443420597; Fri, 07 Jul 2017 09:03:40 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.169.139 with HTTP; Fri, 7 Jul 2017 09:03:39 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: <0b2f0634-e8af-4e93-5cd4-3471d968cb2c@list.imperialat.at> References: <105535b4-a629-b2e4-c5e9-a75ff565b054@list.imperialat.at> <0b2f0634-e8af-4e93-5cd4-3471d968cb2c@list.imperialat.at> Date: Fri, 7 Jul 2017 12:03:39 -0400 X-Google-Sender-Auth: tnaGT5RsCjHiYLbuLCx79Wy_BOQ Message-ID: To: Martijn van Duren Cc: Niklas Keller , Bob Weinand , Kalle Sommer Nielsen , Internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Getting fd from stream From: pollita@php.net (Sara Golemon) On Fri, Jul 7, 2017 at 11:04 AM, Martijn van Duren 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