Created
June 17, 2013 20:20
-
-
Save AlexArchive/5799995 to your computer and use it in GitHub Desktop.
Check if a TCP port is available / already in use on local machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static bool PortAvailableForListening(int portNumber) | |
{ | |
IPEndPoint[] activeTcpListeners = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners(); | |
return activeTcpListeners.Select(x => x.Port == portNumber).FirstOrDefault(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment