列出所有已经使用的端口:
Dim properties As System.Net.NetworkInformation.IPGlobalProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()
Dim ipendpoints As System.Net.IPEndPoint() = Nothing
Output.Show("TCP:")
ipendpoints = properties.GetActiveTcpListeners()
For Each ipendpoint As System.Net.IPEndPoint In ipendpoints
Output.Show(ipendpoint.Port)
Next
Output.Show("----------------------")
Output.Show("UDP:")
ipendpoints = properties.GetActiveUdpListeners()
For Each ipendpoint As System.Net.IPEndPoint In ipendpoints
Output.Show(ipendpoint.Port)
Next