开发者

gen_tcp send io error

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜