Voting

: min(five, nine)?
(Example: nine)

The Note You're Voting On

sahel dot nuri at outlook dot com
7 years ago
This little, important fact would save your time.
If you want to recognize that your client is disconnected without any message, you have to select the right flag.
Because, if you use the flag PHP_BINARY_READ:
<?php
function read($sock){
while(
$buf = @socket_read($sock, 1024 [, PHP_BINARY_READ ]))
if(
$buf = trim($buf))
break;

return
$buf;
}
?>
and the users disconnects, the function will returns an empty string.
But if you use the flag PHP_NORMAL_READ:
<?php
function read($sock){
while(
$buf = @socket_read($sock, 1024, PHP_NORMAL_READ))
if(
$buf = trim($buf))
break;

return
$buf;
}
?>
the function will returns a false.

I hope this will help you. I wasted one hour of my time to solve this problem.

<< Back to user notes page

To Top