When reading from remote with a timeout, return NULL if nothing received
This commit is contained in:
parent
60d17ea297
commit
5a62d69913
@ -284,10 +284,10 @@ final class SocketClient {
|
|||||||
*
|
*
|
||||||
* @param int $timeout How long to wait for data
|
* @param int $timeout How long to wait for data
|
||||||
* @param int $len The amount of data we want
|
* @param int $len The amount of data we want
|
||||||
* @return string
|
* @return string|null
|
||||||
* @throws SocketException
|
* @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
|
// We have data in our buffer
|
||||||
if ($this->rx_left >= $len) {
|
if ($this->rx_left >= $len) {
|
||||||
@ -301,7 +301,7 @@ final class SocketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($timeout AND ($this->hasData($timeout) === 0))
|
if ($timeout AND ($this->hasData($timeout) === 0))
|
||||||
return '';
|
return NULL;
|
||||||
|
|
||||||
$buf = '';
|
$buf = '';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user