Re: [patch] allow socket_[gs]et_options() to work on streams
| From: | Gustavo Lopes | Date: | Mon, 07 Mar 2011 09:40:11 +0000 |
| Subject: | Re: [patch] allow socket_[gs]et_options() to work on streams | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51591@lists.php.net to get a copy of this message | ||
Em Mon, 07 Mar 2011 09:18:24 -0000, Stas Malyshev <smalyshev@sugarcrm.com> escreveu:
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 LopesLet 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.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.