I want to iterate UDP port from 5000 to 50xx
How can I check if a specific port is already open or free to use?
I use this code but it always returns false:
public bool PortIsUsed(int myport)
{
bool alreadyinuse = (from p in System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners() where p.Port == myport select p).Count() == 1;
return alreadyinuse;
}