3
votes

I've some problem with Sockets UDP in Python:

I've a software which receives a message in input from a socket and then do some elaborations before wait for another message from the socket. Let's suppose that in the meanwhile more messages arrive:

If I'm right, they go in a buffer (FIFO) and everytime I listen the socket, I read the oldest one, right?

Is there a way to delete the buffer and everytime read the next message? I want to ignore all the oldest messages...

Another problem is that I've like a tons of message every seconds. How can I empty the buffer if they continue to fill it?

1

1 Answers

1
votes

I also met the same problem. The solution I chose is to turn off socket when I don't need to receive data. Reopen it when I need it. So the data in the buffer is emptied.