jdp/redisent — comment on commit 62f739aaf8ce52fea53c3523353668d9bf5c9a39
File:  line 0
By ivantumanov:

While using your code, I had an issue with the way fread works in read-buffered environments. $read += $block_size increments the amount of information you've read by what you were expecting to read. fread however can return less than the requested quantity of bytes when its waiting for packets from the network. Additionally, fread can return a hard FALSE if it fails or disconnects. I recommend replacing

$response .= fread($this->__sock, $block_size);
$read += $block_size;

with

$r = fread($this->__sock, $block_size);
if ($r !== false) {
$read += strlen($r);
$response .= $r;
} else {
return null;
}