December 30th Monday 2009

来源:互联网 发布:阿里巴巴数据图片尺寸 编辑:程序博客网 时间:2024/06/01 15:29

-module(test_tcp).
-compile(export_all).

go(S) ->
    send("192.168.1.99", 9001, S).

send(Host, Port, Str) ->
    {ok, Socket} = gen_tcp:connect(Host, Port, [binary, {packet, 0}]),
    ok = gen_tcp:send(Socket, Str),
    wait(Socket).

wait(Socket) ->
    receive
        {tcp, Socket, Bin} ->
            io:format("Client received binary = ~p~n", [Bin]),
            wait(Socket);
        {tcp_closed, Socket} ->
            io:format("A connection is shut down. ~n"),
            gen_tcp:close(Socket)
    end.

 

  The above is a little erlang program to test the biogine program during developing.

原创粉丝点击