Determining TCP send queue empty

Does anyone have a recommendation for the best way to know when a
terminal device file is completely done transmitting, even if it’s a pty
on a telnet session?

Something like tcdrain(), but that guarantees that the TCP stack has no
unacked data to be sent?

Thanks,

lew

Lewis Donzis <lew@nospam.donzis.com> wrote:

Does anyone have a recommendation for the best way to know when a
terminal device file is completely done transmitting, even if it’s a pty
on a telnet session?

Something like tcdrain(), but that guarantees that the TCP stack has no
unacked data to be sent?

There are so many places where data may be buffered I think the only
way to be sure that it is received by the other end if if the other end
device/application sends some kind of ACK that your application reads.


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

There are so many places where data may be buffered I think the only
way to be sure that it is received by the other end if if the other end
device/application sends some kind of ACK that your application reads.

There is no special application… the other end is telnet. I just want
to be able to find out when the TCP send queue for the socket associated
with stdout is completely empty.

lew

I don’t see an easy way to do this generally. If you want an indication at
close() you can use the SO_LINGER socket option.

-seanb

Lewis Donzis <lew@nospam.donzis.com> wrote:

There are so many places where data may be buffered I think the only
way to be sure that it is received by the other end if if the other end
device/application sends some kind of ACK that your application reads.

There is no special application… the other end is telnet. I just want
to be able to find out when the TCP send queue for the socket associated
with stdout is completely empty.

lew