In some cases, I want to explicitly discard packets waiting on the socket, with minimal overhead. There doesn't seem to be an explicit drop udp buffer system call, but maybe I'm wrong?
The next best way would probably be to pass the recvpacket to a temporary buffer and just drop it. It seems I canβt get 0 bytes, as the person is talking about recv: The return value will be 0 when the peer has performed an orderly shutdown.So, 1 is the minimum in this case.
Is there any other way to handle this?
Just in case, this is not a premature optimization. The only thing this server does is forwarding / sending UDP packets in a certain way - although recvwith len=1not killing me, I would rather just drop the entire queue at a time with some more specific function (hopefully reducing latency).
source
share