c#UDPClient。随机接收未接收的数据包

问题描述 投票:0回答:1

我有一个程序,后台工作人员不断读取Windows托管的wifi网络上由arduino发送的udp数据包。从1809更新到Windows 10 1909之后,该程序随机停止工作。

[我安装了wireshark以检查我是否完全接收到任何数据,UPD数据包从arduino IP到端口10001的流量持续不断,但是程序停留在udpclient.receive。

这是后台工作者的代码:

        UdpClient udpClient = new UdpClient(10001);
        IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Parse("192.168.137.4"), 10001);
        byte[] receiveBytes;
        ardunoPacketTimer.Start();
        try
        {
            while (worker.CancellationPending == false)
            {
                receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
                //When whatever is going wrong happens, the program doesn't get past here
                SendArduinoData2Joystick(receiveBytes);
            }
        }
c# .net udpclient
1个回答
0
投票

尝试在添加一些日志记录的同时添加catch语句,因此您不只是丢弃可能发生的异常。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.