anchor.diff:  initial() ->
       Addr = {127,0,0,1},
       Port = 6379,
  +    Pass = undef,
       Sock = connect(Addr, Port),
  +
  +    case do_auth(Pass) of
  +        true -> send_auth(Sock, Pass);
  +        false -> false
  +    end,
  +    send_ping(Sock).
  +
  +send_ping(Sock) ->
       case ping(Sock) of
           ok ->
               recv_sock(Sock);
           {error, timeout} ->
  -            io:format("Send timeout, closing! ~n"),
               gen_tcp:close(Sock),
               throw(timeout);
           {error, OtherSendError} ->
  -            io:format("Error over initial socket ~n"),
  +            gen_tcp:close(Sock),
  +            throw(OtherSendError)
  +    end.
  +
  +send_auth(Sock, Pass) ->
  +    case auth(Sock, Pass) of
  +        ok ->
  +            case recv_sock(Sock) of
  +                {ok, _} ->
  +                    ok;
  +                {error, Error} ->
  +                    gen_tcp:close(Sock),
  +                    throw(Error)
  +            end;
  +        {error, OtherSendError} ->
               gen_tcp:close(Sock),
               throw(OtherSendError)
       end.
  
positive.code:          code_change/3]).
  
  -define(RDB_FILE, "/tmp/master/dump3.rdb").
  -define(SB, <<" ">>). % Binary space bar
  -define(CRLF, <<"\r\n">>).
  
  -record(state, {runid="?",
  
negative.code: handle_cast(replication, S = #state{socket=Sock, state=stream}) ->
      io:format("receive stream ~n"),
      inet:setopts(Sock, [{active,once}]),
      {noreply, S};
  
  %% Generic
  