0

I have a C application which receives a lot of data over a TCP socket. Is it somehow possible to get the kernel buffer size for that file descriptor / socket? I would like to know how much data is still in the kernel for the file-descriptor I have.

Thanks a lot

1 Answer 1

2

You can use the SIOCINQ/FIONREAD ioctl:

int bytes_left;
ioctl(sock, FIONREAD, &bytes_left);

This “returns the amount of queued unread data in the receive buffer.” SIOCINQ is defined in linux/sockios.h (on Linux), FIONREAD in sys/ioctl.h.

To retrieve the buffer capacity for the socket, use getsockopt with SO_RCVBUF.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.