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;
}
}