+ 1

Receive multiple packets in a UdpClient

I'm making an app that connects to a UDP server that sends multiple packets with different byte sizes, but the problem is that my UdpClient only can receive 1 packet and I want to receive 8 packets, I have tried to make 8 byte arrays and call the client.Receive() function but still not sending the 8 packets. Packet Sizes: Packet1 - 1341 bytes Packet2 - 147 bytes Packet3 - 841 bytes Packet4 - 841 bytes Packet5 - 25 bytes Packet6 - 1082 bytes Packet7 - 1085 bytes Packet8 - 1061 bytes Code: UdpClient client = new UdpClient(20777); IPEndPoint ep = new IPEndPoint(IPAddress.Any, 0); void UpdateData() { while (true) { // Receive data from Server byte[] arr = client.Receive(ref ep); // Print to console how much data has been sent Console.WriteLine(arr.Length.ToString()); // Output: 1085 (Packet7 Size) } }

31st Aug 2018, 3:57 PM
Alejandro Ramos
Alejandro Ramos - avatar
1 Réponse
+ 1
Well, UDP is not 'reliable' like TCP. Are you getting any ICMP back at the server? What's Wireshark/tcpdump say? FYI, some people here review udp code too: https://codereview.stackexchange.com/questions/tagged/udp
31st Aug 2018, 6:37 PM
Kirk Schafer
Kirk Schafer - avatar