From 62d77d3bb8e7215d9da9ecf6f5aeda0b69f805f8 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 08 十二月 2020 18:57:15 +0800
Subject: [PATCH] 20201208
---
HDL_ON/DAL/DriverLayer/UdpSocket.cs | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
index f63851c..3ffb628 100644
--- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs
+++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -25,7 +25,7 @@
/// <summary>
/// 鍚姩Socket鎺ユ敹鍜屽彂閫佸姛鑳�
/// </summary>
- public void Start (int port)
+ public void Start (int port = 0)
{
if (IsRunning)
{
@@ -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