-module(a).
-compile(export_all).



srv() ->
    {ok, LS} = gen_tcp:listen(5678,[{active, false}, binary]),
    {ok, A} = gen_tcp:accept(LS),
    srv(A, gen_tcp:recv(A, 100)).

srv(Fd, {ok, Bin}) ->
    io:format("Got ~p bytes\n", [size(Bin)]),
    srv(Fd, gen_tcp:recv(Fd, 100));
srv(Fd, Err) ->
    io:format("ERR: ~p~n", [Err]).





cli() ->
    {ok, Fd} = gen_tcp:connect(localhost, 5678, [{active, false}]),
    gen_tcp:send(Fd, lists:duplicate(150, $A)),
    gen_tcp:close(Fd).

    

