3 ms·
A very important point every develeper should know: successful write(2) syscall doesn't not grantee that the data received by a remote application. TCP is descr
by citrin_ru 6y ago
A very important point every develeper should know: successful write(2) syscall doesn't not grantee that the data received by a remote application. TCP is described as a protocol which grantees packet delivery and this often misleading.
write(2) syscall returned without a error means that data has been placed in OS kernel buffer. OS kernel then will try to send it to a remote host. If couple packet will be lost it's not a problem - kernel will retry a few times. But if power will be lost shortly after a write, data may never hit the wire. Then there is possibility that network link will be broken for a long time. OS will retry, but for a limited time and then will give up. Also remote host can crash at any time before remote application actually will read the data.
So if you need reliable delivery you need acknowledgement on application protocol level despite the fact that TCP already have acknowledgements.