Em Mon, 07 Mar 2011 09:18:24 -0000, Stas Malyshev <smalys...@sugarcrm.com> 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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to