using System.Net;
using System.Net.Sockets;

namespace Flo.Installer.Provisioning;

internal static class PortScanner
{
    public static int FindFreeLoopbackPort()
    {
        using var listener = new TcpListener(IPAddress.Loopback, 0);
        listener.Start();
        int port = ((IPEndPoint)listener.LocalEndpoint).Port;
        listener.Stop();
        return port;
    }
}
