Here's my solution for Exercise 4-1: An Echo Server.
%% Erlang Programming
%% Exercise 4-1: An Echo Server
-module(echo).
-export([start/0,print/1,stop/0]).
-export([loop/0]).
start() ->
register(echo, spawn(echo, loop, [])),
ok.
print(Msg) ->
echo ! {print, Msg},
ok.
stop() ->
echo ! stop,
ok.
loop() ->
receive
{print, Msg} ->
io:format("~w~n", [Msg]),
loop();
stop ->
true
end.
--
Erlang Programming Website:
http://www.erlangprogramming.org/