Skip to content

Instantly share code, notes, and snippets.

@herpdederp
Created June 14, 2019 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herpdederp/34f15e923a2cece09c5acda0b5220211 to your computer and use it in GitHub Desktop.
Save herpdederp/34f15e923a2cece09c5acda0b5220211 to your computer and use it in GitHub Desktop.
bool inUse = false;
System.Net.NetworkInformation.IPGlobalProperties ipProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
System.Net.IPEndPoint[] ipEndPoints = ipProperties.GetActiveUdpListeners();
foreach (System.Net.IPEndPoint endPoint in ipEndPoints)
{
if (endPoint.Port == port)
{
inUse = true;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment