[英]UDP Packets Not being received
I'm trying to program a simple data collection gui. 我正在尝试编写一个简单的数据收集GUI。 The setup is as follows:
设置如下:
On one end, I have a programmed FPGA that's sending out simple UDP packets filled with data. 一方面,我有一个编程的FPGA,可以发送填充了数据的简单UDP数据包。 This portion of the system is working - it's been verified, and I can see the packets coming in as expected in wireshark.
系统的这一部分正在工作-已经过验证,我可以看到这些数据包按预期在Wireshark中传入。
On the other, I'm trying to build a simple receiver in C# to collect the packets and display the data. 另一方面,我试图用C#构建一个简单的接收器来收集数据包并显示数据。 I've tried everything I can find on UDP communications, however, and I can't seem to get the GUI to actually see any of the packets.
我已经尝试了所有可以在UDP通信中找到的内容,但是似乎无法让GUI实际看到任何数据包。
The packets are being sent from 192.168.0.99:1024 to 192.168.0.100:1024. 数据包将从192.168.0.99:1024发送到192.168.0.100:1024。
My test code is as follows: 我的测试代码如下:
private void ConnectToUDP(UDPOptions Options)
{
UdpClient listener = new UdpClient(1024);
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, 1024);
while (true)
{
byte[] bytes = listener.Receive(ref groupEP);
}
}
However, I can't seem to get it to do anything but block on the final line. 但是,除了在最后一行上阻塞之外,我似乎无法做任何事情。 (Ie it blocks, but never seems to actually receive any of the data.)
(即,它阻止了,但似乎从未真正接收到任何数据。)
Again, I can see the packets coming in on wireshark, I have my IP address on my machine set to 192.168.0.100 to actually acknowledge the incoming packets, but my program just won't see them. 再次,我可以看到数据包通过wireshark传入,我将机器上的IP地址设置为192.168.0.100以实际确认传入的数据包,但程序却看不到它们。
Anyone have any idea what I'm doing wrong? 有人知道我在做什么错吗?
Thanks, Ian 谢谢,伊恩
Dont know if you still need this or even if this would work for you but @INCyr, try changing the IPEndPoint port from 1024 to 0, like so: 不知道您是否仍然需要这个,或者即使它适合您,但@INCyr,请尝试将IPEndPoint端口从1024更改为0,如下所示:
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, 0);
This worked for me. 这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.