[erlang-questions] How does Erlang TCP determine the end of a TCP stream?
Vimal Kumar
vimal7370@REDACTED
Tue Oct 31 16:25:33 CET 2017
Hi,
I believe you are using with the inet:setopts/2 'active' option set to
true? Set it to false or once and then use gen_tcp:recv/2,3 to read from
tcp stream upto the length you want.
http://erlang.org/doc/man/inet.html#setopts-2
On Tue, Oct 31, 2017 at 8:11 PM, code wiget <codewiget95@REDACTED> wrote:
> Hello,
>
> From my understanding, tcp is a stream based protocol, and you can’t
> really tell one packet from another. You can make sure the packets arrive
> in order, but whether or not they should be “grouped” is not seen by the
> application layer.
>
> But somehow Erlang ssl and tcp abstract this away.
>
> In my code, I have some sort of the following:
>
> Handle_info({tcp/ssl, Sock, Data}, State) -> … and every time that I
> receive data into the socket, it comes as the “full package”, meaning that
> when another server sends a message to it over the socket, It is received
> as the full length of the packet every time with no extra bytes here or
> there. On the other hand, a co-worker’s server has to implement socket
> reads and can’t determine one “group” from another. They have to read in
> the length or set delimiters.
>
>
> What is special about OTP that delimits these packets?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171031/19a3cdb6/attachment.htm>
More information about the erlang-questions
mailing list