Is it possible to query how many bytes are in a socket’s send buffer in linux? I’d like to be able to query SO_SNDBUF with getsockopt to get the buffer size and then [insert technique here] to get the actual usage, which will let me know how much I’m filling up the buffer.
Share
That’s not what
SO_SNDBUFdoes.SO_SNDBUFsets or gets the maximum socket send buffer in bytes (quotingsocket(7)). You could probably use theSIOCOUTQorTIOCOUTQioctls if you’re using tcp or udp.However, it’s highly unlikely this is the right approach. Have you considered using a select-like mechanism to notify you when a socket is writable ? Combined with nonblocking behavior it could be the ticket to a clean approach.