anchor.diff:  handle_info({loading, eof}, State) ->
       io:format("rdb synchronization completed ~n"),
       {noreply, State};
  -%%Generic
  +
  +handle_info({tcp, Sock, Data}, State) ->
  +    io:format("tcp stream: '~p' '~p'~n",[Data, State]),
  +    inet:setopts(Sock, [{active,once}]),
  +    {noreply, State};
  +%% Generic
   handle_info(Msg, State) ->
       io:format("Generic info: '~p' '~p'~n",[Msg, State]),
       {noreply, State}.
  
positive.code:             {error, "Generic error"}
      end.
  
  recv_repl(Sock) ->
      inet:setopts(Sock, [{active,once}]),
      receive
          {tcp, Sock, <<"+OK", _/binary>>} ->
              {ok, psync};
          {tcp, _Sock, <<"-ERR Unrecognized REPLCONF", _/binary>>} ->
              {ok, sync};
          {tcp, _Sock, Data} ->
              io:format("invalid data received '~p' ~n", [Data]),
              {error, "invalid data received"};
          {tcp_closed, Sock} ->
              io:format("Socket ~w closed [~w]~n", [Sock ,self()]),
              {error, "Tcp socket was closed"};
          _ ->
              {erorr, "Generic error"}
      end.
  
  recv_pong(Sock) ->
      inet:setopts(Sock, [{active,once}]),
      receive
          {tcp, Sock, <<"+PONG", _/binary>>} ->
              {ok, pong, Sock};
          {tcp, Sock, Data} ->
              io:format("invalid data received '~p' ~n", [Data]),
              {error, "invalid data received for pong"};
          {tcp_closed, Sock} ->
              io:format("Socket ~w closed [~w]~n",[Sock ,self()]),
              {error, "Tcp socket was closed"}
      end.
  
  tcp_connect(Addr, Port) ->
      gen_tcp:connect(Addr, Port, [binary, {active, false}]).
  
negative.code:             throw(OtherSendError)
      end.
  
  recv_sock(Sock) ->
      inet:setopts(Sock, [{active,once}]),
      receive
          % "-LOADING"
          {tcp, Sock, <<"+OK", _/binary>>} ->
              {ok, psync};
          {tcp, Sock, <<"+PONG", _/binary>>} ->
              {ok, pong, Sock};
          {tcp, Sock, <<"+FULLRESYNC", _, RunId:40/binary, _, Offset/binary>>} ->
              {ok, fullresync, b2l(RunId), int_offset(Offset)};
          {tcp, _Sock, <<"-ERR Unrecognized REPLCONF", _/binary>>} ->
              {ok, sync};
          {tcp, _Sock, <<Bulk/binary>>} ->
              {ok, load_stream, Bulk};
          {tcp, _Sock, Data} ->
  