/// <summary> /// Returns and reserves a new port /// </summary> public int GetNextOpenPort() { lock (_lock) { PortWatcher portWatcher = new PortWatcher(); int newAvailablePort = portWatcher.FindOpenPort(_startPort); _startPort = newAvailablePort + 1; return newAvailablePort; } }
/// <summary> /// Returns and reserves a new port /// </summary> public int GetNextOpenPort() { lock (_lock) { PortWatcher portWatcher = new PortWatcher(); int newAvailablePort = portWatcher.FindOpenPort(_startPort); _startPort = newAvailablePort + 1; return(newAvailablePort); } }
public static IPortWatcher CreatePortWatcher() { IPortWatcher portwatcher = null; switch (Environment.OSVersion.Platform) { case PlatformID.Unix: portwatcher = new UnixPortWatcher(); break; default: portwatcher = new PortWatcher(); break; } return(portwatcher); }