A getsockopt call using SO_RCVBUF returns the allocated socket receive buffer size.
I am wondering if it is possible to query how many packets of datagrams (or bytes) are actually in the buffer before recv or recvfrom called? If this helps, I can agree on a specific Linux answer. This socket is UDP, but I suspect it does not matter for TCP.
The reason I ask is for testing and debugging only. I am trying to check if my call to setocktop (SO_RCVBUF) is of sufficient size. Knowing whether the receive buffer has ever been close to reaching its limit, it will check if a sufficient size has been set.
source share