When reading from remote with a timeout, return NULL if nothing received

This commit is contained in:
Deon George 2023-08-10 11:08:55 +10:00
parent 60d17ea297
commit 5a62d69913

View File

@ -284,10 +284,10 @@ final class SocketClient {
*
* @param int $timeout How long to wait for data
* @param int $len The amount of data we want
* @return string
* @return string|null
* @throws SocketException
*/
public function read(int $timeout,int $len=1024): string
public function read(int $timeout,int $len=1024): ?string
{
// We have data in our buffer
if ($this->rx_left >= $len) {
@ -301,7 +301,7 @@ final class SocketClient {
}
if ($timeout AND ($this->hasData($timeout) === 0))
return '';
return NULL;
$buf = '';