A
A
Alexeytur2018-12-22 15:27:03
C++ / C#
Alexeytur, 2018-12-22 15:27:03

Why doesn't UdpClient.Receive() drop packets?

I have a server application that generates random numbers in an infinite loop and sends them via UdpClient.Send() to a broadcast multicast address.
There is a client application that also receives packets in an endless loop using UdpClient.Receive(). It's okay for now. Now I want to simulate packet loss - before UdpClient.Reсeive() I put Thread.Sleep(1000). But there is no loss - after the slip, the client receives the next packet in order of departure, as if there was no slip, and the packets were stored somewhere in an intermediate place. Moreover, even if the server is terminated, the client will continue to receive packets from somewhere until it receives all sent by the server.
What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2018-12-22
@Alexeytur

The UdpClient has a buffer in which the received data is added.
Its size is available (get set) in the ReceiveBufferSize property.
If the data arrives, but you haven't read it, then the data is overwritten in a circle - that is, packet loss occurs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question