diff --git a/src/Weheartwebsites/SOCKS5/Client.php b/src/Weheartwebsites/SOCKS5/Client.php index 9fe6554..aee427e 100644 --- a/src/Weheartwebsites/SOCKS5/Client.php +++ b/src/Weheartwebsites/SOCKS5/Client.php @@ -300,7 +300,9 @@ public function recv($length) $buffer = @fread($this->socket, $length - mb_strlen($result, 'ASCII')); // If the buffer actually contains something then add it to the result - if ($buffer !== false) { + // Note that fread() will return '' (empty string) when a timeout occurs unlike socket_read() which returns false... + // https://www.php.net/manual/zh/function.fread.php#115340 + if ($buffer !== "") { $result .= $buffer; @@ -393,4 +395,4 @@ private function negotiate() // run login return $this->methods[$response['method']]->authenticate($this); } -} \ No newline at end of file +}