What happens when UDP socket isn't read fast enough?
Two things can happen:
- old data is overwritten with new one with some round-robin algorithm
- new data is simply discarded leaving old data in the buffers
Or there is something else going on?
EDIT:
I would really like some hands-on experi开发者_StackOverflow中文版ence at this, advice about TCP or mere speculation is what I can provide to myself also :)
The newer packets start getting discarded once socket buffer gets full.
It depends on the hardware buffer too. If it is full, the packet is simply ignored too (= same as if it never reached the device and equivalent as if the software buffer in the IP stack is not read fast enough). Both buffers can end-up full independently. In other words, you can loose a datagram at two levels.
The short answer is that you will lose some UDP-packets. I hope you have chosen UDP because can live with some data loss. If you can't, then TCP is the answer.
(You can either just loose the data, and be fine, or implement your own acknowledgement protocol to have packets resend, but then TCP looks like the answer)
精彩评论