anchor.diff:  -record(state, {conns = gb_trees:empty(),      % conn records keyed by Socket
                   tags = gb_trees:empty(),       % tags to ports
                   interval = ?DEFAULT_INTERVAL,  % how often to get stats
  -                limit = ?DEFAULT_LIMIT,        % 
  +                limit = ?DEFAULT_LIMIT,        %
                   clear_after = ?DEFAULT_CLEAR,  % how long to leave errored sockets in status
                   stats = ?INET_STATS,           % Stats to read
                   opts  = ?INET_OPTS,            % Opts to read
  
positive.code: handle_info(measurement_tick, State0 = #state{limit = Limit, stats = Stats,
                                               opts = Opts, conns = Conns}) ->
      State = schedule_tick(State0),
      Fun = fun(Socket, Conn = #conn{type = Type, ts_hist = TSHist, hist = Hist}) when Type /= error ->
                    try
                        {ok, StatVals} = inet:getstat(unwrap_socket(Socket), Stats),
                        TS = os:timestamp(), % read between the two split the difference
                        {ok, OptVals} = safe_getopts(Socket, Opts),
                        Hist2 = update_hist(OptVals, Limit,
                                            update_hist(StatVals, Limit, Hist)),
                        Conn#conn{ts_hist = prepend_trunc(TS, TSHist, Limit),
                                  hist = Hist2}
                    catch
                        _E:_R ->
                            %io:format("Error ~p: ~p\n", [_E, _R]),
                            %% Any problems with getstat/getopts mark in error
                            erlang:send_after(State#state.clear_after,
                                              self(),
                                              {clear, Socket}),
                            Conn#conn{type = error}
                    end;
               (_Socket, Conn) ->
                    Conn
            end,
      {noreply, State#state{conns = gb_trees:map(Fun, Conns)}};
  handle_info({clear, Socket}, State = #state{conns = Conns}) ->
      {noreply, State#state{conns = gb_trees:delete_any(Socket, Conns)}}.
  
  unwrap_socket({sslsocket, Socket, _}) ->
      unwrap_socket(Socket);
  
  unwrap_socket({gen_tcp, Socket, _}) ->
      Socket;
  
  unwrap_socket({gen_tcp, Socket}) ->
      Socket;
  
  unwrap_socket(Socket) ->
      Socket.
  
  safe_getopts(Socket, Opts) ->
      inet:getopts(unwrap_socket(Socket), Opts).
  
  terminate(_Reason, _State) ->
      lager:info("Shutting down TCP Monitor"),
  
negative.code: init(Props) ->
      lager:info("Starting TCP Monitor"),
      ok = net_kernel:monitor_nodes(true, [{node_type, visible}, nodedown_reason]),
      % blow up here if any state fields would not be sane so subsequent code
      % can assume they're positive integers
      State0 = #state{
          interval = pos_int_value(
              proplists:get_value(interval, Props, ?DEFAULT_INTERVAL)),
          limit = pos_int_value(
              proplists:get_value(limit, Props, ?DEFAULT_LIMIT)),
          clear_after = pos_int_value(
              proplists:get_value(clear_after, Props, ?DEFAULT_CLEAR))},
      DistCtrl = erlang:system_info(dist_ctrl),
      State = lists:foldl(fun({Node,Port}, DatState) ->
              add_dist_conn(Node, Port, DatState)
      end, State0, DistCtrl),
     {ok, schedule_tick(State)}.
  
  pos_int_value(Val) when erlang:is_integer(Val) andalso Val > 0 ->
      Val.
  
  handle_call(status, _From, State = #state{conns = Conns,
                                            status_funs = StatusFuns}) ->
  