Re: Socket Rework Complete
| From: | J Smith | Date: | Fri, 08 Mar 2002 16:22:08 +0000 |
| Subject: | Re: Socket Rework Complete | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-80934@lists.php.net to get a copy of this message | ||
I don't think that's a hot idea. The return value of select() is an int for
reason and not merely true or false. It's supposed to return the number of
file descriptors that are ready for reading, writing or exceptions.
According to the man file:
"On success, select and pselect return the number of descriptors contained
in the descriptor sets, which may be zero if the timeout expires before
anything interesting happens. On error, -1 is returned, and errno is set
appropriately; the sets and timeout become undefined, so do not rely on
their contents after an error."
Returning true or false probably isn't a good idea -- how are you supposed
to know how many file descriptors are available if the answer is either 1
or 0?
Another function may be needed that can take a peek at the number of ready
file descriptors if you really want socket_select() to return true/false.
I'm thinking that this functionality is a bit too far removed from the
standard select() call, though. (Although without the functions equivalent
to the FD_* macros', the extension as a whole is getting pretty far removed
from the standard sockets library as it is.)
J
Jason Greene wrote:
>>
>> The way I would go about fixing it would be to change socket_select() to
>> return true or false, and if there was an error (as indicated by retval),
>> store errno somewhere and let socket_last_error()/socket_clear_error()
>> retrieve that value if there isn't a socket specified.
>
> I agree with this approach, however, IMO this is a functionality
> enhancement (soring a global last error), and probably should wait till
> 4.3.0.
>
> Thoughts anyone?
>