I would like to add delivery confirmation to my TCP interface. A non-blocking write could populate the send buffer, but the data might never arrive if the connection fails - meanwhile write has reported that the data was received (by the local socket).
If I added extra acks to the stack, I could verify each piece of data was received. I think ftp does this. But I can't borrow anyone's code and would rather not implement ack/resend, particularly since TCP does most of this already.
I think it can be accomplished if I can verify that the socket send buffer is empty after each write(). If there's no more data, it should have all been delivered. I don't mind the latency of emptying the buffer.
Edit: I realize TCP/socket implementations differ by system, but if there's a Berkeley or Linux solution, it's probably available to me.
Edit: To address some suggestions, I would like to implement three levels of TCP interface, where I don't know how to accomplish the *'d one.
Actually acking stuff at application level is the only way. Here are a few issues:
When you send data, even if it leaves your kernel it's not done until your TCP receives an ACK about it. The API doesn't provide you with this information.
The fact that your application received an ACK can mean:
recv. Maybe it crashes before getting a chance to recv.In conclusion:
TCP ACKsSo you need an application-level ACK, but of course without retransmissions. The ACK should merely tell you "I received and processed your data".
I see you persevere in your idea. Go look for SIOCOUTQ as described in a few Linux manual pages. Of course it's Linux-onlye, but see if it does what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With