anchor.diff:       MsgQueueLen          :: non_neg_integer(),
        DesiredBundleSize    :: non_neg_integer(),
        MsgsSinceBundleStart :: non_neg_integer(),
  -     LastStatReport       :: stat_report()}.
  +     LastStatReport       :: stat_report(),
  +     NumberOfTimeouts	  :: non_neg_integer()}.
   -type message() ::
       {send, DestPid::pid(), Message::comm:message(), Options::comm:send_options()} |
       {tcp, Socket::inet:socket(), Data::binary()} |
  
positive.code:      _StartTime = os:timestamp(), _SentMsgCount = 0, _ReceivedMsgCount = 0,
       _MsgQueue = {[], []}, _Len = 0,
       _DesiredBundleSize = 0, _MsgsSinceBundleStart = 0,
       _LastStatReport = {0, 0, 0, 0} }.
  
  -spec dest_ip(state()) -> inet:ip_address().
  dest_ip(State)                 -> element(1, State).
  
negative.code:             ?TRACE("~.0p Sent message ~.0p~n",
                     [pid_groups:my_pidname(), Message]),
              ?LOG_MESSAGE_SOCK('send', Message, byte_size(BinaryMessage), channel(State)),
              set_number_of_timeouts(State, 0);
          {error, closed} ->
              Address = dest_ip(State),
              Port = dest_port(State),
              report_bundle_error(Options, {Address, Port, Pid}, Message,
                                  socket_closed),
              log:log(warn,"[ CC ~p ] sending closed connection", [self()]),
              close_connection(Socket, set_number_of_timeouts(State, 0));
          {error, timeout} ->
              NumberOfTimeouts = number_of_timeouts(State),
              if  % retry 5 times
                  NumberOfTimeouts < 5 ->
                      log:log(error,"[ CC ~p ] couldn't send to ~.0p:~.0p (~.0p). retrying.",
                              [self(), dest_ip(State), dest_port(State), timeout]),
                      send_internal(Pid, Message, Options, BinaryMessage, set_number_of_timeouts(State, NumberOfTimeouts + 1));
                  true ->
                      log:log(error,"[ CC ~p ] couldn't send to ~.0p:~.0p (~.0p). retried 5 times, now closing the connection.",
                              [self(), dest_ip(State), dest_port(State), timeout]),
                      Address = dest_ip(State),
                      Port = dest_port(State),
                      report_bundle_error(Options, {Address, Port, Pid}, Message,
                                          socket_timeout),
                      close_connection(Socket, set_number_of_timeouts(State, 0))
              end;
          {error, Reason} ->
              Address = dest_ip(State),
              Port = dest_port(State),
  