How to tell how much data is in a Socket's send buffer

妖精的绣舞 提交于 2019-12-05 16:12:36

UDP socket does not have a send buffer. The meaning of the SO_SNDBUF socket option for UDP is the limit on the size of the datagram you can send. The kernel usually does have a packet queue per NIC, but that is combined for all protocols, and there's no user-land API to query its size. IP layer, and then the hardware, can drop packets silently. TCP knows how to deal with that, UDP doesn't. So unless .Net or whatever other Microsoft miracle has such buffering in user-land libraries, you are out of luck.

The recourse is for receivers to signal the sender about dropped packets, request resends, fall back to TCP, etc. This also implies having some sort of sequencing from the sender.

Hope this helps.

Can you analyze the header? There might be information about content length.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!