简体   繁体   中英

UDP Packets Not being received

I'm trying to program a simple data collection gui. The setup is as follows:

On one end, I have a programmed FPGA that's sending out simple UDP packets filled with data. This portion of the system is working - it's been verified, and I can see the packets coming in as expected in wireshark.

On the other, I'm trying to build a simple receiver in C# to collect the packets and display the data. 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.

The packets are being sent from 192.168.0.99:1024 to 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.

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:

IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, 0);

This worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM