BlockStudio.Ethereum.GethService.GetPortAndInstanceUse C# (CSharp) Method

GetPortAndInstanceUse() public static method

public static GetPortAndInstanceUse ( string port ) : GethInstanceState
port string
return GethInstanceState
        public static GethInstanceState GetPortAndInstanceUse(string port)
        {
            var portValue = Int32.Parse(port);
            var portAvailable = true;

            var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
            var tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections();

            foreach (var tcpi in tcpConnInfoArray)
            {
                if (tcpi.LocalEndPoint.Port == portValue)
                {
                    portAvailable = false;
                    break;
                }
            }

            //var processes = Process.GetProcessesByName("geth");
            //if (processes.Length > 0)
            //{
                
            //    return GethInstanceState.InstanceRunning;
            //}

            if (portAvailable)
            {
                return GethInstanceState.NoInstanceRunning;
            }
            else
            {
                return GethInstanceState.InstanceRunning;
            }
        }