I am working on a simple network application under Linux, where I need to read the following two properties:
The receive buffer (1st property) could be obtained using FIONREAD option of ioctl() function. But for the second property (bytes# in send buffer) I am not sure how can I read that. I have tried the SO_SNDBUF option in getsockopt() function, but it turn out to be the maximum size of sending buffer rather than current size of data in send buffer.
Any thoughts or suggestions?
Here is how to obtain,
The length of data in Receive Buffer which is not read yet:
ioctl( socket_descriptor, FIONREAD, &size ); // alternative 1
ioctl( socket_descriptor, SIOCINQ, &size ); // alternative 2
The length of data in Send Buffer which is not drained yet (either not sent yet or send but not acknowledged by receiver):
ioctl( socket_descriptor, TIOCOUTQ, &size ); // alternative 1
ioctl( socket_descriptor, SIOCOUTQ, &size ); // alternative 2
Reference: http://linux.die.net/man/7/tcp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With