IPAddress ip = IPAddress.Parse("192.168.0.188"); IPAddress IPLocal = IPAddress.Parse("192.168.0.110"); Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { clientSocket.Bind(new IPEndPoint(IPLocal, 0)); //绑定本地通讯使用的网卡IP clientSocket.Connect(new IPEndPoint(ip, 502)); } catch { clientSocket.Shutdown(SocketShutdown.Both); clientSocket.Close(); return; }