xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -21,15 +21,15 @@
      //本地Socket
      private Socket busSocket;
      int _port = 0;
      public int Port = 0;
      /// <summary>
      /// 启动Socket接收和发送功能
      /// </summary>
      public void Start (int port)
      public void Start (int port = 0)
        {
         if (IsRunning)
         {
                if (port == _port)
                if (port == Port)
                {
                    return;
                }
@@ -38,15 +38,17 @@
                    busSocket.Close();
                }
            }
            _port = port;
         if (port != 0)
            Port = port;
         if (Port == 0)
            return;
            busSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            busSocket.EnableBroadcast = true;
            try {
                //busSocket.Bind (new IPEndPoint (IPAddress.Any, 6000));
                busSocket.Bind(new IPEndPoint(IPAddress.Any, port));
            busSocket.Bind(new IPEndPoint(IPAddress.Any, Port));
                busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188")));
            busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188")));
         }
         catch{
                busSocket = null;
@@ -133,7 +135,7 @@
            //mqtt连接数据读取  A协议网络设备信息读取回复 处理
            if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585)
            {
               Control.Ins.ConvertReceiveData(bytes);
               Control.Ins.ConvertReceiveData(bytes, ((IPEndPoint)packet.RemoteEndPoint).Address.ToString());
            }
            else if(((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//处理bus 6000端口的数据
            {