Browse Source

MiniServer,修正 GetPort 方法无法获取本地监听端口的问题。

master
王厅 1 month ago
parent
commit
7c59b4399f
  1. 13
      Apewer/Web/MiniServer.cs

13
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;
}

Loading…
Cancel
Save