Speaking of the FD_* macros and such, I'm trying to visualize how to 
re-write some code that I have that relies on the socket_fd_* functions. If 
you get the chance, could you look over this simplified version of what I'm 
doing and point me towards the proper direction to get it working with the 
new API. I want to have this stuff ready when PHP 4.2 or 4.3 come out, and 
seeing as you're the one closest to the sockets extension, I thought you 
could give me some pointers as to how it would work with the abscence of 
the sockets_fd_* functions. (I'm a little confused what to do without the 
FD_* stuff. This could make for a good example in the documentation, 
anyways, if it works as hoped.)

Attached is the stripped-down source.

J


Jason Greene wrote:

> 
> The correct behavior that is consistent with the API follows(that I am
> planning):
> Set retval of socket_select() to be the number of file descriptors
> available. If error occurs set to false.
> 
> Using the c-api one commonly writes code like this
> --------------------------------------------------
> Error on an actual error or no sockets available:
> 
> ret=select(rfds, NULL, NULL, &tv);
> if (ret < 0)
>    error_func();
> 
> Error differently:
> 
> ret=select(rfds, NULL, NULL, &tv);
> if (ret == -1)
>     error_sys();
> if (ret == 0)
>     error_noavail();
> 
> 
> The equiv in php using false:
> ------------------------------
> 
> Error on an actual error or no sockets available:
> 
> $ret=socket_select($rfds, NULL, NULL, 1);
> if (ret == 0)
>    error_func();
> 
> Error differently:
> 
> $ret=socket_select($rfds, NULL, NULL, 1);
> if (ret === FALSE)
>    error_sys();
> if (ret === 0)
>    error_noavail();
> 
> 
>> According to the man file:
>>
> 
>> (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
> 
> Yes, the goal is to follow a more php like behavior. Those who follow
> the C-API will have some slight adjusting to, but the beauty of the
> high-level language is that we can automate and simplify the
> functionality.
> 
> This also makes it easier for people who don't know C to pickup the
> functionality.
> 
> -Jason
>> --
>> PHP Development Mailing List <http://www.php.net/>
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 


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

Reply via email to