From a513de686060a0a2846933b32d654fd721fec947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 1 Mar 2021 15:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Server.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 5498ca74..8b98e959 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -179,12 +179,17 @@ class Server extends HttpService if (empty($port)) { return false; } - if (Snowflake::isLinux()) { - exec('netstat -tunlp | grep ' . $port[0]['port'], $output); - } else { - exec('lsof -i :' . $port[0]['port'] . ' | grep -i "LISTEN"', $output); + foreach ($port as $value) { + if (Snowflake::isLinux()) { + exec('netstat -tunlp | grep ' . $value['port'], $output); + } else { + exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"', $output); + } + if (!empty($output)) { + return true; + } } - return !empty($output); + return false; } @@ -340,7 +345,13 @@ class Server extends HttpService } - private function addListener($config) + /** + * @param $config + * @return Http|Packet|Receive|Websocket|null + * @throws NotFindClassException + * @throws ReflectionException + */ + private function addListener($config): Packet|Websocket|Receive|Http|null { if ($this->isUse($config['port'])) { return $this->error_stop($config['host'], $config['port']);