есть сервер:
-module(server).
-export([start/0]).
start() ->
{ok, ListenSocket} = gen_tcp:listen(1234, [binary, {active, false}, {packet, 4}]),
wait_connect(ListenSocket, 0).
wait_connect(ListenSocket, Count) ->
{ok, Socket} = gen_tcp:accept(ListenSocket),
spawn(?MODULE, wait_connect, [ListenSocket, Count+1]),
get_request(Socket).
get_request(Socket) ->
case gen_tcp:recv(Socket, 0) of
{ok, Binary} ->
Term = binary_to_term(Binary), %% завершается с ошибкой
Size = tuple_size(Term),
io:format("Term: ~p Size: ~p Binary: ~p~n", [Term, Size, Binary]),
gen_tcp:close(Socket);
{error, closed} ->
error_logger:info_msg("Error", [])
end.
ему отправляется запрос примерно таким образом
//...
m_pTcpSocket = new QTcpSocket(this);
//...
QByteArray arrBlock;
QDataStream out(&arrBlock, QIODevice::WriteOnly);
ei_x_buff result;
ei_x_new_with_version(&result);
ei_x_encode_tuple_header(&result, 1);
ei_x_encode_longlong(&result, 1555);
out << result.buff;
m_pTcpSocket->write(arrBlock);
в результате вылетает данная ошибка:
** exception error: bad argument
in function binary_to_term/1
called as binary_to_term(<<131,104,1,98,0>>)
in call from server:get_request/1 (server.erl, line 18)