Reputation: 21817
I try to send data with gen_tcp:send:
gen_tcp:send(Socket, <<"Test message">>).
but get error:
** exception exit: {badarg,[{io,format,[<0.31.0>,"~p~n",<<"4">>]},
{erl_eval,do_apply,5},
{shell,exprs,7},
{shell,eval_exprs,7},
{shell,eval_loop,3}]}
in function io:o_request/3
How can i fix it?
Thank you.
Upvotes: 0
Views: 132
Reputation: 5327
From the error message I'm guessing you have done this:
io:format("~p~n",gen_tcp:send(Socket,<<"Test message">>)).
you need to wrap your call inside a list. i.e.
io:format("~p~n",[gen_tcp:send(Socket,<<"Test message">>)]).
See the io module documentation for details on why.
Upvotes: 4