[erlang-questions] gen_tcp:send {error, timeout} and ways to restore situation?

Jesper Louis Andersen <>
Mon Sep 12 20:44:33 CEST 2016


On Mon, Sep 12, 2016 at 7:55 PM, Max Lapshin <> wrote:

> Is it possible to understand, how many data from packet have been sent to
> OS and try to restore situation on socket and resend the rest of packet
> again?


Isn't this impossible to know? I assume you are setting the send_timeout
option, since according to the documentation, there is no way which a
gen_tcp:send/2 can time out.

The problem is that a TCP connection has no way of knowing where your bytes
are "hiding" so to speak. The Erlang system might have buffered them and
the OS never accepts receiving them. Or the OS has received the bytes, but
they are in a TCP window buffer in the kernel somewhere. Or the bytes are
in the outgoing TX ring-buffer of your network device. Or traveling through
the internet, but getting lost somewhere. Or is sitting somewhere in the
receiving hosts buffer queues, but not delivered yet. Or they have been
delivered, but you don't know that this is the case.

You need to write your protocol for best effort delivery in general.
Otherwise you are in trouble.


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160912/1db88df1/attachment.html>


More information about the erlang-questions mailing list