Actually, I just reread your response again.

socket_select returns NULL on a SELECT error, this does not mean that it
will return an error on a socket IN the set you are selecting on that
has errored.

In the case of a socket you are selecting on has errored, the socket
will show up as readable. You then can perform a socket_read/recv, and
you should receive NULL (errored socket), then you can call
socket_last_error to receive the errno.

If the socket has hit an eof your socket_read would have returned a 0
len string, socket_recv would return 0 bytes, and socket_select would
have shown the socket to be readable.

All in all, socket_get_status is designed for the abstracted interface
fsockopen, and not for the lowlevel socket. The way it does this is by
performing the steps suggested by J. Smith and myself above.

Also, if you want to just check for an error on a socket, and you don't
want to read your data (which you should rarely have to do) there is a
MSG_PEEK option you can pass socket_recv that will allow you to look
ahead and not clear.

Thanks,
-Jason





 Sun, 2002-04-28 at 22:56, Jason Greene wrote:
> On Sun, 2002-04-28 at 18:31, J Smith wrote:
> > 
> > One way to find which socket has died, if any, is to loop through each 
> > socket in the three sets (read/write/exceptions) and do a select() on each 
> > one to see if you can read with a timeout of 0. (The bad one being the one 
> > where select() returns -1, I think.)
> > 
> > J
> > 
> 
> socket_select returns NULL on error. 
> 
> -Jason
> > 
> > Steve Meyers wrote:
> > 
> > > There's only one thing it's missing -- the equivalent of
> > > socket_get_status(), which is not part of the extension, despite the name.
> > > If I set my socket to nonblocking, the only way to tell if it has died is
> > > to try to write to it, which isn't always a desirable thing to do :)
> > > 
> > > Unless there's another way that I just don't understand.
> > > 
> > 
> > 
> > -- 
> > 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
> 



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

Reply via email to