Skip to content

Commit

Permalink
add __destruct method
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Jan 12, 2024
1 parent 726463e commit 27fbf92
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Xash3D/Master.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public function __construct(
}
}

public function __destruct()
{
fclose(
$this->_socket
);
}

public function getServersIPv6(
int $limit = 100,
string $region = "\xFF",
Expand All @@ -59,10 +66,6 @@ public function getServersIPv6(
// 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;
Expand All @@ -71,10 +74,6 @@ public function getServersIPv6(
// Skip header
if (false === fread($this->_socket, 6))
{
fclose(
$this->_socket
);

$this->_errors[] = _('Could not init packet header');

return null;
Expand Down Expand Up @@ -141,11 +140,6 @@ public function getServersIPv6(
];
}

// Close connection
fclose(
$this->_socket
);

return $servers;
}

Expand Down

0 comments on commit 27fbf92

Please sign in to comment.