anchor.diff:          {error, Reason} -> % BUG in here!!
               {stop, socket_err, {S, Reason}}
       end;
  +
  +handle_sock(ok, S = #state{socket=Sock, state=reconnect2}) ->
  +    case recv_sock(Sock) of
  +        {ok, _} ->
  +            gen_server:cast(self(), bar),
  +            {noreply, S#state{state=reconnect3}};
  +        {error, Reason} ->
  +            {stop, socket_err, {S, Reason}}
  +    end;
   %% Receive the payload from de synchronization command 'sync'
   handle_sock(ok, S = #state{socket=Sock, state=load, mode=sync}) ->
       io:format("getting payload sync ~n"),
  
positive.code:     {noreply, State};
  
  handle_info({tcp, Sock, Data}, S = #state{state=stream, mode=sync}) ->
      inet:setopts(Sock, [{active,once}]),
      io:format("sync tcp stream: '~p' '~p'~n",[Data, S]),
      {noreply, S};
  
  handle_info({tcp, Sock, Data}, S = #state{state=stream, mode=psync}) ->
      inet:setopts(Sock, [{active,once}]),
      io:format("psync tcp stream: '~p' '~p'~n",[Data, S]),
      NewOffset = (S#state.offset + byte_size(Data)),
      {noreply, S#state{offset=NewOffset}, ?REPL_TIMEOUT};
  
  %% Psync mode need to send offset data periodically
  %% in order to maintain the slavery active in socket.
  handle_info(timeout, S = #state{socket=Sock, offset=Offset, mode=psync, state=stream}) ->
      io:format("REPLCONF ack '~p' ~n", [S]),
      repl_ack(Sock, Offset),
      {noreply, S, ?REPL_TIMEOUT};
  
  handle_info({tcp_closed, _Sock}, S) ->
      io:format("tcp connection closed from master '~p' ~n", [S]),
      {noreply, S};
  handle_info({tcp_error, _Sock, Reason}, S) ->
      io:format("tcp connection error from master '~p' ~n", [S]),
      {stop, Reason};
  
negative.code:     inet:setopts(Sock, [{active,once}]),
      receive
          % "-LOADING"
          % "+CONTINUE"
          {tcp, _Sock, <<"+OK", _/binary>>} ->
              {ok, psync};
          {tcp, Sock, <<"+PONG", _/binary>>} ->
              {ok, pong, Sock};
          {tcp, _Sock, <<"+CONTINUE", _, _, Data/binary>>} ->
              {ok, continue, Data};
          {tcp, _Sock, <<"+FULLRESYNC", _, RunId:40/binary, _, Offset/binary>>} ->
              {ok, fullresync, b2l(RunId), int_offset(Offset)};
          {tcp, _Sock, <<"-ERR Unrecognized REPLCONF", _/binary>>} ->
              {ok, sync};
  