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

namespace Common
{
    public static class PortFinder
    {
        public static int FreeTcpPort()
        {
            var l = new TcpListener(IPAddress.Loopback, 0);
            l.Start();
            var port = ((IPEndPoint)l.LocalEndpoint).Port;
            l.Stop();
            return port;
        }
    }
}