From 26315c924f64353e519c2ac2e513bf6e0f18e9d2 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 16 Dec 2023 15:49:41 +0200 Subject: [PATCH] require internal validation --- src/Socket.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Socket.php b/src/Socket.php index 3e3a269..3fe5ecd 100644 --- a/src/Socket.php +++ b/src/Socket.php @@ -30,14 +30,19 @@ class Socket public static function isOpen(string $host, int $port = -1, ?float $timeout = null, int &$error_code = null, string &$error_message = null): bool { - return is_resource( - @fsockopen( - $host, - $port, - $error_code, - $error_message, - $timeout - ) - ); + if (self::isHost($host) && self::isPort($port)) + { + return is_resource( + @fsockopen( + $host, + $port, + $error_code, + $error_message, + $timeout + ) + ); + } + + return false; } } \ No newline at end of file