From 673aacdb31fed68924418f094a0e6640b7e6b21b Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 16 Dec 2023 14:57:43 +0200 Subject: [PATCH] implement port open check --- src/Port.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Port.php diff --git a/src/Port.php b/src/Port.php new file mode 100644 index 0000000..3f381c0 --- /dev/null +++ b/src/Port.php @@ -0,0 +1,43 @@ + $length; + } + + 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 + ) + ); + } +} \ No newline at end of file