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;
            }

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2021-05-22
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
  • 2021-12-21
  • 2022-01-06
相关资源
相似解决方案