Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51591 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35757 invoked from network); 7 Mar 2011 09:40:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Mar 2011 09:40:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:52217] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/33-17187-FF7A47D4 for ; Mon, 07 Mar 2011 04:40:16 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 74F557000456 for ; Mon, 7 Mar 2011 09:40:12 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id JPDkIOzO8uqy for ; Mon, 7 Mar 2011 09:40:12 +0000 (WET) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 2F3A87000438 for ; Mon, 7 Mar 2011 09:40:12 +0000 (WET) Received: from clk-0081.clk-domain (unknown [85.139.253.17]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 22D672008639 for ; Mon, 7 Mar 2011 09:40:12 +0000 (WET) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <43.60.54597.484527D4@pb1.pair.com> <4D7436E8.7010802@sugarcrm.com> <4D74A2E0.3090304@sugarcrm.com> Date: Mon, 07 Mar 2011 09:40:11 -0000 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: <4D74A2E0.3090304@sugarcrm.com> User-Agent: Opera Mail/11.01 (Win32) Subject: Re: [PHP-DEV] [patch] allow socket_[gs]et_options() to work on streams From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") Em Mon, 07 Mar 2011 09:18:24 -0000, Stas Malyshev escreveu: >>> I think we already have PHP_STREAM_AS_SOCKETD, which should be >>> appropriate here, not? >> >> That will indeed give you a socket descriptor, but >> 1) it's not directly available to user-space. >> 2) you still have to create a socket extension resource in order to pass >> it to functions of that extension. > > Let socket functions deal with it - just see if it's a stream, use > AS_SOCKETD on it. They don't really need resource, they just need FD - > they'll get it one way or another. > That was indeed the original proposal, except it was limited to socket_get_option and socket_set_option. In fact, the socket extension doesn't just need the file descriptor. Some functions also need to know whether the socket is in blocking mode and its type (AF_INET/AF_INET6/AF_UNIX/etc); see http://lxr.php.net/opengrok/xref/PHP_TRUNK/ext/sockets/php_sockets.h#82 . I suppose this information could be queried, but would you want to do the cast and retrieve this data in every call say in a socket_read loop? I also don't think magically mixing PHP streams and socket resources is a good idea, users may start to think PHP streams and socket resources are interchangeable and will be (even more) confused when they can't use socket resources with the stream functions. -- Gustavo Lopes