From efad979b6fae76fb37a4de7e94e6bac0a85cb72c Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 30 十一月 2021 13:14:28 +0800 Subject: [PATCH] 2021-11-30 1.修复乐橙Android,没调用拒接接口问题。 --- HDL_ON/DAL/DriverLayer/UdpSocket.cs | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs index 376e6bb..4946986 100644 --- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs +++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs @@ -21,29 +21,32 @@ //鏈湴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, Port)); busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188"))); } -- Gitblit v1.8.0