anchor.diff:            "ref=~p",
             log_info(State, [MS, Ref])),
       State#state{reconnect_tref = Ref}.
  -
  -%% cancel_timer(S = #state{reconnect_tref = undefined}) -> S;
  -%% cancel_timer(S = #state{reconnect_tref = Ref}) when is_reference(Ref) ->
  -%%     erlang:cancel_timer(Ref),
  -%%     S#state{reconnect_tref = undefined}.
   
   %% @private
   tcp_good(State = #state{}) ->
  
positive.code:     ?ERR("drain_id=~p channel_id=~p dest=~s state=~p "
           "err=gen_tcp data=~p sock=~p duration=~s",
            log_info(State, [StateName, Reason, Sock, duration(State)])),
      {next_state, disconnected, reconnect(tcp_bad(State))};
  handle_info({inet_reply, Sock, {error, Reason}}, StateName,
              State = #state{sock = Sock}) ->
      ?ERR("drain_id=~p channel_id=~p dest=~s state=~p "
           "err=gen_tcp data=~p sock=~p duration=~s",
            log_info(State, [StateName, Reason, Sock, duration(State)])),
      {next_state, disconnected, reconnect(tcp_bad(State))};
  handle_info({tcp_closed, Sock}, StateName, State) ->
      ?INFO("drain_id=~p channel_id=~p dest=~s state=~p "
            "err=gen_tcp data=~p sock=~p duration=~s",
            log_info(State, [StateName, closed, Sock, duration(State)])),
      {next_state, disconnected, reconnect(tcp_bad(State))};
  handle_info(Info, StateName, State) ->
      ?MODULE:StateName(Info, State).
  
  
negative.code: %% @doc Time has finally come to reconnect. Attempt the reconnection,
  %% send buffered messages on success, schedule a delayed reconnect if
  %% not.
  -spec do_reconnect(#state{}) ->
                            {next_state, pstate(), #state{}}.
  do_reconnect(State = #state{sock = undefined,
                              reconnect_tref = undefined}) ->
      case connect(State) of
  