Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51578 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99848 invoked from network); 5 Mar 2011 20:36:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2011 20:36:42 -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:60381] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/E2-15662-6DE927D4 for ; Sat, 05 Mar 2011 15:36:39 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id A48DB7000447 for ; Sat, 5 Mar 2011 20:36:34 +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 cqllL-EGLAoe for ; Sat, 5 Mar 2011 20:36:34 +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 6007D700043C for ; Sat, 5 Mar 2011 20:36:34 +0000 (WET) Received: from cataphract (cataphract.cata.lo.geleia.net [IPv6:2001:470:94a2:1:b488:8610:90e4:7835]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 53B11200147F for ; Sat, 5 Mar 2011 20:36:33 +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> Date: Sat, 05 Mar 2011 20:35:36 -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_IST?= Message-ID: In-Reply-To: <43.60.54597.484527D4@pb1.pair.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") On Sat, 05 Mar 2011 15:19:31 -0000, Vincent NEGRIER wrote: > The goal of this patch is to allow user handling of low level socket > options for stream sockets created with stream_socket_*() or fsockopen() > functions. > > I choose to extend the socket_get_options() and socket_set_options() > functions and keep the functionality inside the sockets extension so > this won't add seldom used "bloat" to streams if built without it. > > With the patch, these two functions check if their first argument is a > stream, and then attempt to cast it to php_sock before trying to fetch > it as a socket resource. > > Patch is here: http://si.kz/php-sockets-stream-options.diff.txt > > Anyone with karma care to comment / commit ? :) > I think a better option would be a function to convert a php socket stream into a socket resource. That would avoid limiting this to socket_get_options/socket_set_options and polluting the socket ext functions prologue with these conversions. And of course, in the long run, the socket streams should support all the operations the socket extension currently does. As to your patch, just by a quick glance, you ought to at least check if the stream represents a socket (see php_stream_is). You also seem to be leaking php_sock and should add some tests. But again, I see this as a more inconsistent and limited approach. -- Gustavo Lopes