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) } }