public void GetPort_Rpc_DefaultPort() { PortTypeUtils.ResetPorts(); var port = PortTypeUtils.GetPortNumber(EPortType.Rpc); Assert.AreEqual(24533, port); }
public void GetPort_MultichainD_DefaultPort() { PortTypeUtils.ResetPorts(); var port = PortTypeUtils.GetPortNumber(EPortType.MultichainD); Assert.AreEqual(7211, port); }
public void GetPortTwice_MultichainD_NextPort() { PortTypeUtils.ResetPorts(); PortTypeUtils.GetPortNumber(EPortType.MultichainD); var port = PortTypeUtils.GetPortNumber(EPortType.MultichainD); Assert.AreEqual(7212, port); }
public void GetPortTwice_Rpc_NextPort() { PortTypeUtils.ResetPorts(); PortTypeUtils.GetPortNumber(EPortType.Rpc); var port = PortTypeUtils.GetPortNumber(EPortType.Rpc); Assert.AreEqual(24534, port); }
public void ResetPorts_GetPortTwice_DefaultPort() { PortTypeUtils.ResetPorts(); var port1 = PortTypeUtils.GetPortNumber(EPortType.MultichainD); PortTypeUtils.ResetPorts(); var port2 = PortTypeUtils.GetPortNumber(EPortType.MultichainD); Assert.AreEqual(port1, port2); }
/// <summary> /// Returns the next available port for specified use. /// Starts from a predefined value for enum /// </summary> /// <returns>An available TPC Port</returns> public static int GetNewPort(EPortType type) { var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); var tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections(); while (true) { // Get port from tool var port = PortTypeUtils.GetPortNumber(type); // Check if our desired port is in use if (tcpConnInfoArray.All(t => t.LocalEndPoint.Port != port)) { // This port is good return(port); } } }