From 5a62d69913f0c4cc4bf72a3ae78db6597730fd30 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 10 Aug 2023 11:08:55 +1000 Subject: [PATCH] When reading from remote with a timeout, return NULL if nothing received --- app/Classes/Sock/SocketClient.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Classes/Sock/SocketClient.php b/app/Classes/Sock/SocketClient.php index dfb6204..3c93bd9 100644 --- a/app/Classes/Sock/SocketClient.php +++ b/app/Classes/Sock/SocketClient.php @@ -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 = '';