[erlang-questions] How does Erlang TCP determine the end of a TCP stream?

Stanislaw Klekot erlang.org@REDACTED
Tue Oct 31 17:21:49 CET 2017


On Tue, Oct 31, 2017 at 12:10:49PM -0400, code wiget wrote:
> Vimal - I am using {active, once}. And I like when it comes in as
> a full packet, so I do not want to change anything that could
> eliminate that behavior.

This behaviour is a coincidence that bases on your Erlang code being
able to keep up with the sender, and as such, it's brittle.

Do a test: wait some time (1s) in your code before setting {active,once}
again and see what you'll get. My bet is several packets clumped
together.

This is how read() and recv() work on stream BSD sockets. If the
socket's buffer is non-empty, they return whatever is in the buffer (up
to read length). There's nothing magical that Erlang would do on the
sockets for {packet,raw}.

-- 
Stanislaw Klekot



More information about the erlang-questions mailing list