feliciaheart
New Member
I wrote a PHP class for a websocket client that allows you to connect to websocket servers from PHP. It works very well, except that it can only read data in an infinite loop. In a websocket connection, the server or the client can send data whenever they want, as many times as they want. Unfortunately, \[code\]socket_select\[/code\], \[code\]socket_read\[/code\], and \[code\]socket_recv\[/code\] won't block if any data has been sent by the other socket - \[code\]socket_select\[/code\] will return immediately, and \[code\]socket_read\[/code\] and \[code\]socket_recv\[/code\] will return an empty string. I tried making the process sleep until it received \[code\]SIGPOLL\[/code\], but that caused it to sleep indefinitely. Is there any way to know more data is available on the socket after data has already been received?