Em Mon, 07 Mar 2011 09:51:31 -0000, Stas Malyshev <smalys...@sugarcrm.com> escreveu:

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'd ask why you need socket_read and not just fread if you use streams? If you need deeper semantics, then yes, either you use resources or you convert. I'm not against the conversion function, per se, but the regular API shouldn't force it's use (see below).

That's a misleading argument. I could write a function that expects a socket resource and it would still work if passed a stream, but with degraded performance and functionality.

The degraded functionality comes from the fact socket_last_error() could no longer be used to retrieve the last error on the socket as PHP streams don't save this information. There may be other issues I'm not aware of.

We don't have alternative to setting socket options on a stream. Neither we want one - why have two functions for doing the same thing?

Because the sockets extension is not enabled by default and it has a different design -- it provides a low-level interface that closely follows the C interface. Compelling functionality should still be added to the streams, hopefully with a friendlier interface than socket_set_option.

--
Gustavo Lopes

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

Reply via email to