Erlang的shell功能强大,这里我将它当成我的客户端。可以动态的输入你需要发送的内容,也可以动态的接收内容,就像调试器一样,在开发过程中起到很重要的作用。具体使用方式如下:
C:\Documents and Settings\Administrator>erl
Eshell V5.10.4 (abort with ^G)
1> {ok, Socket} = gen_tcp:connect("localhost", 2000, [binary, {packet, 2}]).
{ok,#Port<0.510>}
2> gen_tcp:send(Socket, "OK").
ok
3> receive
{tcp, Socket, String} ->
io:format("Client received = ~p~n", [String])
after 1000 ->
exit
end.
Client received = <<"OK">>
ok
具体内容不解释了。
时间: 2024-10-10 15:34:07