From 5eeafe3af80bfd88306bd8ad9e76c8f4b51ca35f Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 14:16:20 +0800
Subject: [PATCH] 增加本地发送的重发机制

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

diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
index 376e6bb..ab3cb02 100644
--- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs
+++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -21,31 +21,35 @@
 
 		//鏈湴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)
-				{
-					return;
+                if (port == Port)
+                {
+                    return;
                 }
                 else
                 {
-					busSocket.Close();
+                    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, port));
+                //busSocket.Bind (new IPEndPoint (IPAddress.Any, 6000));
+                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;

--
Gitblit v1.8.0