From fd1f19e8479c764fa28b0da3a2f9b34a3debe772 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 03 八月 2023 21:47:04 +0800
Subject: [PATCH] 2023年08月03日21:47:02
---
HDL_ON/DAL/DriverLayer/UdpSocket.cs | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
index 4f78319..36637f9 100644
--- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs
+++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -50,8 +50,10 @@
busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188")));
}
- catch{
- busSocket = null;
+ catch (Exception ex){
+ MainPage.Log ($"udp port bind error : {ex.Message}");
+
+ busSocket = null;
return;
}
@@ -75,7 +77,7 @@
}
catch { }
busSocket = null;
- MainPage.Log("Socket鍏抽棴");
+ MainPage.Log("Socket鍏抽棴");
}
/// <summary>
@@ -120,9 +122,12 @@
{
return;
}
-
try
{
+ if (busSocket == null)
+ {
+ return;
+ }
asyncBeginReceive();
Packet packet = (Packet)iar.AsyncState;
int len = busSocket.EndReceiveFrom(iar, ref packet.RemoteEndPoint);
@@ -137,10 +142,11 @@
{
Control.Ins.ConvertReceiveData(bytes, ((IPEndPoint)packet.RemoteEndPoint).Address.ToString());
}
- else if(((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹�
+ else if (((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹�
{
packet.Manager();
}
+
}
catch (Exception ex)
{
--
Gitblit v1.8.0