From e1a8f2f7e4d850beedeb1469610b878c1427e976 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 15 十二月 2021 09:01:53 +0800
Subject: [PATCH] 更新

---
 HDL_ON/DAL/DriverLayer/UdpSocket.cs |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
index f63851c..4f78319 100644
--- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs
+++ b/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绔彛鐨勬暟鎹�
 				{

--
Gitblit v1.8.0