TcpPort.cscsharp

Documentation

Lilith.DesktopWeb2App (Version 2)

Windows desktop shell (WebView2 + local Kestrel) hosting Lilith.RazorWebGui for Version 2.

dotnet run --project Lilith.DesktopWeb2App.csproj

Requires [WebView2 Runtime](https://developer.microsoft.com/microsoft-edge/webview2/).

using System.Net;using System.Net.Sockets;namespace Lilith.DesktopWeb2App;internal static class TcpPort{    internal static int FindFree()    {        var listener = new TcpListener(IPAddress.Loopback, 0);        listener.Start();        int port = ((IPEndPoint)listener.LocalEndpoint).Port;        listener.Stop();        return port;    }}