Hi I have this situation:
gen_tcp:connect(Address, Port, [{buffer, 1024},{active, false},{packet,0},{send_timeout, infinity}]).
and I use gen_tcp:recv(Sock,0)
, but the message from the server don't have a particular end pattern, so there's any way to prevent client blocks on recv?
From doc:
do_recv(Sock, Bs) ->
case gen_tcp:recv(Sock, 0) of
{ok, B} ->
do_recv(Sock, [Bs, B]);
{error, closed} ->
{ok, list_to_binary(Bs)}
end.