From 7c59b4399f35e4cefd01efbdb2ad2ebdf25e666d Mon Sep 17 00:00:00 2001 From: Elivo Date: Wed, 23 Apr 2025 11:51:13 +0800 Subject: [PATCH] =?UTF-8?q?MiniServer=EF=BC=8C=E4=BF=AE=E6=AD=A3=20GetPort?= =?UTF-8?q?=20=E6=96=B9=E6=B3=95=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=9B=91=E5=90=AC=E7=AB=AF=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer/Web/MiniServer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Apewer/Web/MiniServer.cs b/Apewer/Web/MiniServer.cs index 618ea42..c6a5ed3 100644 --- a/Apewer/Web/MiniServer.cs +++ b/Apewer/Web/MiniServer.cs @@ -133,8 +133,15 @@ namespace Apewer.Web int GetPort() { var socket = _socket; - if (socket != null) return 0; - try { if (socket.LocalEndPoint is IPEndPoint ipep) return ipep.Port; } catch { } + if (socket == null) return 0; + try + { + if (socket.LocalEndPoint is IPEndPoint ipep) + { + return ipep.Port; + } + } + catch { } return 0; } @@ -203,7 +210,7 @@ namespace Apewer.Web catch (Exception ex) { Shutdown(); - Logger.Web.Exception(this, ex); + Logger.Web.Exception(ex, this); CatchException?.Invoke(ex); return; }