Skip to content

Commit

Permalink
add connection close
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Dec 16, 2023
1 parent a64b7ac commit cc9ddf3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ public static function isOpen(string $host, int $port = -1, ?float $timeout = nu
{
if (self::isHost($host) && self::isPort($port))
{
return is_resource(
@fsockopen(
$host,
$port,
$error_code,
$error_message,
$timeout
)
$connection = @fsockopen(
$host,
$port,
$error_code,
$error_message,
$timeout
);

if (is_resource($connection))
{
return fclose(
$connection
);
}
}

return false;
Expand Down

0 comments on commit cc9ddf3

Please sign in to comment.