Browse Source

add __destruct method

main 1.0.1
ghost 12 months ago
parent
commit
27fbf92c6b
  1. 20
      src/Xash3D/Master.php

20
src/Xash3D/Master.php

@ -40,6 +40,13 @@ class Master
} }
} }
public function __destruct()
{
fclose(
$this->_socket
);
}
public function getServersIPv6( public function getServersIPv6(
int $limit = 100, int $limit = 100,
string $region = "\xFF", string $region = "\xFF",
@ -59,10 +66,6 @@ class Master
// Filter query // Filter query
if (false === fwrite($this->_socket, "1{$region}{$host}:{$port}\0\gamedir\t{$gamedir}\0")) if (false === fwrite($this->_socket, "1{$region}{$host}:{$port}\0\gamedir\t{$gamedir}\0"))
{ {
fclose(
$this->_socket
);
$this->_errors[] = _('Could not send socket query'); $this->_errors[] = _('Could not send socket query');
return null; return null;
@ -71,10 +74,6 @@ class Master
// Skip header // Skip header
if (false === fread($this->_socket, 6)) if (false === fread($this->_socket, 6))
{ {
fclose(
$this->_socket
);
$this->_errors[] = _('Could not init packet header'); $this->_errors[] = _('Could not init packet header');
return null; return null;
@ -141,11 +140,6 @@ class Master
]; ];
} }
// Close connection
fclose(
$this->_socket
);
return $servers; return $servers;
} }

Loading…
Cancel
Save