anchor.diff:  % 3- start slave phase
   %    3.1 - [repl]
   %    3.2 - [capa] check if servr is psync compat with capa eof
  +%    3.3 - [sync|psync]
  +
  +
  +%% Handle the receiving data in socket depending
  +%% in which state is.
  +handle_sock(ok, S = #state{socket=Sock, state=list}) ->
  +    case recv_ok(Sock) of
  +        ok ->
  +            gen_server:cast(self(), capa),
  +            {noreply, S#state{state=eof}}; % Next state will be 'eof'
  +        {error, Error} ->
  +            {stop, socket_err, {S, Error}}
  +    end;
  +handle_sock(ok, S = #state{socket=Sock, state=eof}) ->
  +    case recv_ok(Sock) of
  +        ok ->
  +            psync;
  +        {error, "invalid data received"} -> %% Fix this for a better treatment
  +            sync;
  +        {error, Error} -> % BUG in here!!
  +            {stop, socket_err, {S, Error}}
  +    end;
  +handle_sock({error, Error}, S) ->
  +    {stop, socket_err, {S, Error}};
  +handle_sock(_,_) ->
  +    {stop, general, "general socket error"}.
  +
   
   initial() ->
       Addr = {127,0,0,1},
  
positive.code: handle_info({loading, eof}, State) ->
      io:format("rdb synchronization completed ~n"),
      {noreply, State};
  handle_info(Msg, State) ->
      io:format("Generic info: '~p' '~p'~n",[Msg, State]),
      {noreply, State}.
  
negative.code: 
  % load_rdb(self()), % load rdb file
  
  %% REPLCONF listening-port.
  %% The initial step, send the repl with our
  %% client tcp port over the socket.
  handle_cast(repl, S = #state{socket=Sock, state=list}) ->
      io:format("repl ~n"),
      handle_sock(repl(Sock), S);
  
  %% REPLCONF capa eof.
  %% Check wheter the server is able to do partial
  %% synchronization or just can handle whole sync.
  handle_cast(capa, S = #state{socket=Sock, state=eof}) ->
      io:format("capa ~n"),
      Type = handle_sock(capa(Sock), S), % BUG: take care of recv errors.
      gen_server:cast(self(), Type),
      {noreply, S#state{state=load}};
  
  %% PSYNC.
  handle_cast(psync, S = #state{socket=_Sock, state=load}) ->
      io:format("psync ~n"),
      {noreply, S};
  
  %% SYNC.
  handle_cast(sync, S = #state{socket=_Sock, state=load}) ->
      io:format("sync ~n"),
      {noreply, S};
  