anchor.diff:      %% Stale message.
       send(State);
   ready_to_send({timeout, _Ref, ?IDLE_TIMEOUT_MSG}, S) ->
  -    close_if_idle(S);
  +    close_if_idle(S, disconnected, ready_to_send);
   ready_to_send({post, Msg}, State = #state{sock = Sock})
     when is_port(Sock) ->
       send(buffer(Msg, State));
  
positive.code:     NewTimer = erlang:start_timer(MaxIdle + Fuzz, self(), ?IDLE_TIMEOUT_MSG),
      State#state{idle_tref = NewTimer}.
  
  close_if_idle(State = #state{sock = Sock, last_good_time = LastGood}) ->
      MaxIdle = logplex_app:config(tcp_syslog_idle_timeout, timer:minutes(5)),
      SinceLastGoodMicros = timer:now_diff(os:timestamp(), LastGood),
      case SinceLastGoodMicros > (MaxIdle * 1000) of
  
negative.code:           log_info(S, [sending, Reason, Sock, duration(S)])),
      reconnect(tcp_bad(S));
  sending({timeout, _, ?IDLE_TIMEOUT_MSG}, State) ->
      close_if_idle(State, disconnecting, sending);
  sending(timeout, S = #state{}) ->
      %% Sleep when inactive, trigger fullsweep GC & Compact
      {next_state, sending, S, hibernate};
  