On non-blocking sockets, the function will return "" if no data is received, and even if the client disconnects.
If you want to check if the client disconnected, use ===.
$ret=socket_read($socket);
$ret=="" : connected but no data received or client disconnected
$ret==="" : client disconnected for sure