mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
Livestatus\Connection: implement readLineFromSocket
We want to stream data in the near future, so reading line by line is essential
This commit is contained in:
parent
a027efc9e7
commit
8ec8c153dd
@ -248,6 +248,28 @@ class Connection
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function readLineFromSocket()
|
||||||
|
{
|
||||||
|
if ($this->bytesRead === $this->responseSize) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$maxRowLength = 100 * 1024;
|
||||||
|
$row = socket_read($this->getConnection(), $maxRowLength, PHP_NORMAL_READ);
|
||||||
|
$this->bytesRead += strlen($row);
|
||||||
|
|
||||||
|
if ($row === false) {
|
||||||
|
$this->socketError('Failed to read next row from livestatus socket');
|
||||||
|
}
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write given string to livestatus socket
|
||||||
|
*
|
||||||
|
* @param string $data Data string to write to the socket
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
protected function writeToSocket($data)
|
protected function writeToSocket($data)
|
||||||
{
|
{
|
||||||
$res = @socket_write($this->getConnection(), $data);
|
$res = @socket_write($this->getConnection(), $data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user