c# socket 判断端口是否被占用
using System.Net; using System.Net.Sockets; using System.Net.NetworkInformation; IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners(); foreach (var item in ipEndPoints) { }