On Tue, 2009-01-13 at 00:31 -0500, Bill Fink wrote:
An excellent article on this subject:
http://ds9a.nl/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable.txt
"Luckily, it turns out that Linux keeps track of the amount of
unacknowledged
data, which can be queried using the SIOCOUTQ ioctl(). Once we see this
number hit 0, we can be reasonably sure our data reached at least the
remote
operating system."
is this the same as the TCP_INFO getsockopt() ?
if you follow the progression from write(socket_fd, ) ... the data sits
in
the socket buffer, and SIOCOUTQ is initially zero. If the connection
started with a zero window,
it could sit like that for a while (sometimes called a "tarpit ?). But,
you should still see the data in your socket buffer, yes?
So, I think you want to make sure your socket write buffer is empty
(converted to unacked data), *then* make sure your unacked data is 0.
write(sock, buffer, 1000000); // returns 1000000
shutdown(sock, SHUT_WR);
now wait for SIOCOUTQ to hit 0.
if window is 0, shutdown() would wait until show device sets window > 0
again, or forever on a tarpitted connection. Either way, when if/when
it finishes, you know all data was transmitted, now wait for all of it
to be ACKed with SIOCOUTQ.
--
Jeremy Jackson
Coplanar Networks
(519)489-4903
http://www.coplanar.netjerj@coplanar.net
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html