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() int GetPort()
{ {
var socket = _socket; var socket = _socket;
if (socket != null) return 0; if (socket == null) return 0;
try { if (socket.LocalEndPoint is IPEndPoint ipep) return ipep.Port; } catch { } try
{
if (socket.LocalEndPoint is IPEndPoint ipep)
{
return ipep.Port;
}
}
catch { }
return 0; return 0;
} }
@ -203,7 +210,7 @@ namespace Apewer.Web
catch (Exception ex) catch (Exception ex)
{ {
Shutdown(); Shutdown();
Logger.Web.Exception(this, ex); Logger.Web.Exception(ex, this);
CatchException?.Invoke(ex); CatchException?.Invoke(ex);
return; return;
} }

Loading…
Cancel
Save