StoryTeller.PortFinder.tryPort C# (CSharp) Méthode

tryPort() private static méthode

private static tryPort ( int port ) : bool
port int
Résultat bool
        private static bool tryPort(int port)
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
            var endpoint = new IPEndPoint(IPAddress.Any, port);

            try
            {
                socket.Bind(endpoint);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                socket.SafeDispose();
            }

        }
    }