[erlang-questions] gen_tcp two way comm

Roberto Ostinelli roberto@REDACTED
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">>),
gen_tcp:recv(Socket,0).

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

Anywhere I should start looking?..

Thank you,

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


More information about the erlang-questions mailing list