[erlang-questions] gen_tcp send non-blocking in erlang?
Mon Mar 17 12:26:39 CET 2014
On 03/17/2014 12:19 PM, Matthias Lang wrote:
> On Monday, March 17, Jon Schneider wrote:
>>> Whether any mechanism in erlang to check the sent message delivary?
>> TCP doesn't so how can Erlang ?
> [This is going beyond what the original poster probably had in mind, but
> it's an interesting problem.]
> TCP _does_ know which data has been ACKed. But that information gets
> lost somewhere between the TCP stack and ordinary programs.
> Something like this:
> could be tweaked so that it really does let Erlang code figure out whether
> or not a particular byte has reached the remote TCP stack.
But the packet may be lost between the remote stack and the remote
program, due to any number of reasons, including bugs and crashes. A way
to know a remote endpoint has truly received the packet and processed it
is to make it send a packet back. But even that is not perfect, as that
"ack" packet can also be lost.
A common way to solve this is to have an auto incremented value for all
messages sent, and if the remote endpoint disconnects for any reasons,
have it send the last value it received when connecting so the local
endpoint knows what it needs to send again.
More information about the erlang-questions