How many packets or bytes are in the socket receive queue?

后端 未结 3 1620
灰色年华
灰色年华 2021-01-03 02:22

Calling getsockopt with SO_RCVBUF will return the allocated size of the socket receive buffer.

I am curious to know if it is possible to

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 02:48

    On Windows, what you are looking for is available via ioctlsocket(FIONREAD) and WSAIoCtl(FIONREAD), which both return the full size of the complete buffered data, even when multiple datagram messages are buffered. However, there is no equivalent on Linux. There is ioctl(FIONREAD), which only returns the size of the next buffered message.

提交回复
热议问题