anchor.diff:  %% @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
  
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:                   MaxExp when F > MaxExp -> Max;
                    _ -> 1 bsl F
                end,
      {next_state, disconnected,
       reconnect_in(timer:seconds(BackOff), State)}.
  
  reconnect_in(MS, State = #state{}) ->
      Ref = erlang:start_timer(MS, self(), ?RECONNECT_MSG),
  