title: Erlang simple server problem
body: <p>As I learn Erlang, I'm trying to solve ex. 4.1 ("An Echo server") from "Erlang Programming" book (by O'Reilly) and I have a problem.
  My code looks like that:</p>
  
  <pre><code>-module(echo).
  -export([start/0, print/1, stop/0, loop/0]).
  
  start() -&gt;
      register(echo, spawn(?MODULE, loop, [])),
      io:format("Server is ready.~n").
  
  loop() -&gt;
      receive
          {print, Msg} -&gt;
              io:format("You sent a message: ~w.~n", [Msg]),
              start();
          stop -&gt;
              io:format("Server is off.~n");
          _ -&gt;
              io:format("Unidentified command.~n"),
              loop()
      end.
  
  print(Msg) -&gt; ?MODULE ! {print, Msg}.
  
  stop() -&gt; ?MODULE ! stop.
  </code></pre>
  
  <p>Unfortunatelly, I have some problems. Turning on works as expected, it spawns a new process and display "Server is ready" message. But when I try to use print function (like <code>echo:print("Some message.").</code> that, for example) I got result, but it doesn't work like I'd like to. It prints my message as a list (not as a string) and it generates</p>
  
  <pre><code>=ERROR REPORT==== 18-Jul-2010::01:06:27 ===
  Error in process &lt;0.89.0&gt; with exit value: {badarg,[{erlang,register,[echo,&lt;0.93.0&gt;]},{echo,start,0}]}
  </code></pre>
  
  <p>error message.
  Moreover, when I try to stop server by <code>echo:stop()</code> I got another error</p>
  
  <pre><code>** exception error: bad argument
   in function  echo:stop/0
  </code></pre>
  
  <p>Could anybody explain me, what's going on here ? I am new to Erlang and it seems to be quite difficult to grasp for me at this time.</p>