Is there a way to find out whether there is data waiting in the buffer of a blocking socket? I need to read out data if it's there, or don't if it's not. Problem with blocking sockets is that once you've begun a read operation, it does not return before that many bytes are actually read, which becomes a problem if those bytes never arrive, since your script just hangs.
I've tried socket_get_status(), which says that it returns the number of unread bytes in the socket buffer, but instead it always returns 0.
I've tried to set the sockets to non-blocking, but I don't really know how to use them that way.
Can anybody help?