From 1293fea19c6a2b558986856e301d5218c1979692 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期五, 27 十一月 2020 14:08:43 +0800 Subject: [PATCH] Revert "20201127 接受bus数据修改完成,搜索网关、一端口修改完成" --- HDL_ON/DAL/DriverLayer/UdpSocket.cs | 21 ++++++--------------- 1 files changed, 6 insertions(+), 15 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs index 376e6bb..39b3dfd 100644 --- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs +++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs @@ -21,29 +21,20 @@ //鏈湴Socket private Socket busSocket; - int _port = 0; + /// <summary> /// 鍚姩Socket鎺ユ敹鍜屽彂閫佸姛鑳� /// </summary> public void Start (int port) { - if (IsRunning) - { - if (port == _port) - { - return; - } - else - { - busSocket.Close(); - } - } - _port = port; + if (IsRunning ) { + return; + } busSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); busSocket.EnableBroadcast = true; try { - busSocket.Bind (new IPEndPoint (IPAddress.Any, port)); + busSocket.Bind (new IPEndPoint (IPAddress.Any, 6000)); busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188"))); } @@ -128,7 +119,7 @@ packet.Bytes = new byte[len]; Array.Copy(bytes, 0, packet.Bytes, 0, packet.Bytes.Length); - //MainPage.Log($"鎺ユ敹{packet.RemoteEndPoint}鏁版嵁"); + MainPage.Log($"鎺ユ敹IP{packet.RemoteEndPoint}鏁版嵁"); //mqtt杩炴帴鏁版嵁璇诲彇 A鍗忚缃戠粶璁惧淇℃伅璇诲彇鍥炲 澶勭悊 if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585) { -- Gitblit v1.8.0