> I wish there were an API to detect how much data still hasn't been acked.
From example code attached to the original article (Linux only):
int outstanding;
ioctl(fd, SIOCOUTQ, &outstanding);