From 27fbf92c6b0c60ddf5ed235f27a5574ed400a10d Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 12 Jan 2024 20:09:20 +0200 Subject: [PATCH] add __destruct method --- src/Xash3D/Master.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Xash3D/Master.php b/src/Xash3D/Master.php index 8442007..2909d64 100644 --- a/src/Xash3D/Master.php +++ b/src/Xash3D/Master.php @@ -40,6 +40,13 @@ class Master } } + public function __destruct() + { + fclose( + $this->_socket + ); + } + public function getServersIPv6( int $limit = 100, string $region = "\xFF", @@ -59,10 +66,6 @@ class Master // Filter query if (false === fwrite($this->_socket, "1{$region}{$host}:{$port}\0\gamedir\t{$gamedir}\0")) { - fclose( - $this->_socket - ); - $this->_errors[] = _('Could not send socket query'); return null; @@ -71,10 +74,6 @@ class Master // Skip header if (false === fread($this->_socket, 6)) { - fclose( - $this->_socket - ); - $this->_errors[] = _('Could not init packet header'); return null; @@ -141,11 +140,6 @@ class Master ]; } - // Close connection - fclose( - $this->_socket - ); - return $servers; }