On Sat, 05 Mar 2011 15:19:31 -0000, Vincent NEGRIER <vnegr...@optilian.com> 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

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

Reply via email to