[erlang-questions] gen_tcp two way comm

Roberto Ostinelli <>
Sun Oct 21 02:00:08 CEST 2012

Hi list,

this should be simple but I don't get what is going on.

On a server:

[...listening and connection...]
{ok, Data} = gen_tcp:recv(Socket, 0),
ok = gen_tcp:send(Socket,<<"some response">>).

Data received from client (see below) is correctly <<"some data">>.

On the client:

{ok, Socket} = gen_tcp:connect("localhost", 8500, [binary, {packet, raw}]),
ok = gen_tcp:send(Socket, <<"some data">>),

Instead of {ok, <<"some response">>}, the last line returns {error,einval}.

Anywhere I should start looking?..

Thank you,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121020/ec04ea08/attachment.html>

More information about the erlang-questions mailing list