echo daemon works well enough

This commit is contained in:
Peter Harpending
2026-09-01 23:01:34 -07:00
parent 997c3d1da3
commit 7aa6f4b863
12 changed files with 352 additions and 272 deletions
+20
View File
@@ -0,0 +1,20 @@
% @doc echo server client
-module(echoc).
-export([main/0]).
main() ->
{ok, Socket} = gen_tcp:connect("localhost", 6969, [binary, {packet, 0}]),
loop(Socket).
loop(Socket) ->
ok = inet:setopts(Socket, [{active, once}]),
receive
{tcp, Socket, Bytes} ->
ok = io:format("< ~tp~n", [Bytes]),
loop(Socket);
{tcp_closed, Socket} ->
ok = io:format("connection terminated~n", []),
exit(normal)
end.