From 32cd05a17e2b7ae8a1d3687996278dc25dd58cc5 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 21 十二月 2020 09:58:05 +0800
Subject: [PATCH] Merge branch 'CJL' into NewFilePath
---
HDL_ON/DAL/DriverLayer/UdpSocket.cs | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
old mode 100644
new mode 100755
index f63851c..ab3cb02
--- 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,13 +38,16 @@
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")));
}
--
Gitblit v1.8.0