Skip to content

Instantly share code, notes, and snippets.

@andriesss
Created October 11, 2012 19:02
Show Gist options
  • Save andriesss/3874752 to your computer and use it in GitHub Desktop.
Save andriesss/3874752 to your computer and use it in GitHub Desktop.
public function getChangedReadStreams()
{
$read = array($this->socket);
$write = array();
$except = array();
return stream_select($read, $write, $except, 5);
}
/**
* @return bool|string
*/
public function read()
{
$done = false;
$response = '';
while (!$done) {
$response .= fread($this->socket, 4096);
if ($this->getChangedReadStreams() == 0) {
$done = true;
}
}
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment