wei
2020-11-27 1293fea19c6a2b558986856e301d5218c1979692
HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -1,9 +1,8 @@
using System;
using System.Net.Sockets;
using System.Net;
using Newtonsoft.Json.Linq;
namespace HDL_ON
namespace HDL_ON.DriverLayer
{
   public class UdpSocket
   {
@@ -26,9 +25,9 @@
      /// <summary>
      /// 启动Socket接收和发送功能
      /// </summary>
      public void Start ()
      public void Start (int port)
        {
            if (IsRunning) {
            if (IsRunning ) {
                return;
            }
@@ -36,6 +35,7 @@
            busSocket.EnableBroadcast = true;
            try {
                busSocket.Bind (new IPEndPoint (IPAddress.Any, 6000));
            busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188")));
         }
         catch{
@@ -45,7 +45,7 @@
            asyncBeginReceive();
            MainPage.Log ($"udp port : 6000");
            MainPage.Log ($"udp port : {port}");
        }
      /// <summary>
@@ -97,10 +97,6 @@
                Console.WriteLine($"asyncBeginReceive {e.Message}");
            } 
      }
      /// <summary>
        /// 搜索网络设备触发的回调事件
        /// </summary>
      public Action<string> SearchNetDeviceAction;
      /// <summary>
      /// 异步接收数据结束
@@ -123,10 +119,11 @@
            packet.Bytes = new byte[len];
            Array.Copy(bytes, 0, packet.Bytes, 0, packet.Bytes.Length);
            MainPage.Log($"接收IP{packet.RemoteEndPoint}数据");
            //mqtt连接数据读取  A协议网络设备信息读取回复 处理
            if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585)
            {
               Common.A_Protocal_Common.apc.ConvertReceiveData(bytes);
               Control.Ins.ConvertReceiveData(bytes);
            }
            else if(((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//处理bus 6000端口的数据
            {