public function _read_buffer($length = XPSPL_SOCKET_READ_LENGTH, $flags = MSG_DONTWAIT)
{
$r = null;
$read = @socket_recv($this->get_resource(), $r, $length, $flags);
if ($read === 0) {
return false;
}
if ($read === false) {
$error = socket_last_error($this->get_resource());
$this->error = $error;
$this->error_str = socket_strerror($this->error);
// Non-blocking IO
if ($error == SOCKET_EWOULDBLOCK || ($error = SOCKET_EAGAIN)) {
++$this->_read_attempted;
return true;
}
return false;
}
$this->_read_attempted = 0;
if ($r !== null) {
if (null === $this->_read_buffer) {
$this->_read_buffer = trim($r);
} else {
$this->_read_buffer .= trim($r);
}
}
return true;
}