I'm using the boost::asio::ip::udp::socket to receive UDP packets via socket's async_receive_from method.
The code works fine, the only problem is that in the time I process a packet, lots more come creating a queue (the buffer) to process. My program though must sink all the packets received since the start of the processing, so that it listens only to the most recent ones.
Example:
- packet 1 is sent
- packet 1 is being processed
- packets 2, 3, 4 are sent
- packet 1 ends the computation
- flush the buffer
- packet 5 is sent
- packet 5 is being processed
- etc
Is there any way to discard the packets in the middle? Thanks!