I established a connection with the client as follows:
gen_tcp:listen(1234,[binary,{packet,0},{reuseaddr,true},{active,false},{recbuf,2048}]).
This code performs message processing:
loop(Socket)->
inet:setops(Socket,[{active,once}],
receive
{tcp,Socket,Data}->
handle(Data),
loop(Socket);
{Pid,Cmd}->
gen_tcp:send(Socket,Cmd),
loop(Socket);
{tcp_close,Socket}->
% ...
end.
My OS is Windows. When the message size is 1024 bytes, I lose bytes in Data. The server sends ACK + FIN to the client.
I believe Erlang is limited to 1024 bytes, so I defined recbuf.
Where is the problem: Erlang, Windows hardware?
Thank.
source
share