Mechanism reqd for knowing TCP buffer occupancy level

Hi,

The description and the context of the mechanism that i require is as follows:

There is an application communicating with a protocol stack binary. There is a TCP socket communication between the two.

Now, the stack is pumping up data to the Application such that the receiving buffer of the Application and the sending buffer of the stack is getting occupied. Basically, the Application is processing messages at a rate slower than that at which the stack is pumping the data to it.

Now the mechanism that i require is that i need a way in which i can get the amount of buffer that has been filled up by the messages in the corresponding TCP buffers.
My aim is to raise an alarm in case the TCP buffer has been filled up to a particular percentage level.

But to do that i need a way of knowing how much of the buffer has been occupied. So how do i get that idea?
Need this urgently. Thanks a lot.
Cheers
Saptarshi,

ioctl(FIONREAD) would be a good start to find out how much a socket has to read.

However the internal buffers are a matter for the kernel really, there is no guarrantee that SIOCGHIWAT,SIOCGLOWAT etc are implemented.

Hi,

Thanks for the reply.
This would not actually map to the requirement i have of knowing the TCP buffer occupancy.

Thanks anyways.

regards
Saptarshi.