anchor.diff:       MsgQueueLen          :: non_neg_integer(),
        DesiredBundleSize    :: non_neg_integer(),
        MsgsSinceBundleStart :: non_neg_integer(),
  -     LastStatReport       :: stat_report(),
  -     NumberOfTimeouts	  :: non_neg_integer()}.
  +     LastStatReport       :: stat_report()}.
   -type message() ::
       {send, DestPid::pid(), Message::comm:message(), Options::comm:send_options()} |
       {tcp, Socket::inet:socket(), Data::binary()} |
  
positive.code: send(Pid, Message, Options, State) ->
      DeliverMsg = {?deliver, Pid, Message},
      BinaryMessage = ?COMM_COMPRESS_MSG(DeliverMsg, State),
      send_internal(Pid, Message, Options, BinaryMessage, State).
  
  -spec send_internal
      (pid(), comm:message(), comm:send_options(), BinMsg::binary(), state())
          -> state();
      (?unpack_msg_bundle, [{pid(), comm:message()}], [comm:send_options()], BinMsg::binary(), state())
          -> state().
  send_internal(Pid, Message, Options, BinaryMessage, State) ->
      Socket = socket(State),
      ?LOG_MESSAGE_SOCK('send', Message, byte_size(BinaryMessage), channel(State)),
      case gen_tcp:send(Socket, BinaryMessage) of
          ok ->
              ?TRACE("~.0p Sent message ~.0p~n",
                     [pid_groups:my_pidname(), Message]),
              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 (~p) ] sending closed connection", [self(), pid_groups:my_pidname()]),
              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 (~p) ] couldn't send message (~.0p). retrying.",
                              [self(), pid_groups:my_pidname(), timeout]),
                      send_internal(Pid, Message, Options, BinaryMessage, set_number_of_timeouts(State, NumberOfTimeouts + 1));
                  true ->
                      log:log(error,"[ CC ~p (~p) ] couldn't send message (~.0p). retried 5 times, now closing the connection.",
                              [self(), pid_groups:my_pidname(), timeout]),
  
negative.code:                                 Reason),
              log:log(error,"[ CC ~p (~p) ] couldn't send message (~.0p). closing connection",
                      [self(), pid_groups:my_pidname(), Reason]),
              close_connection(Socket, State)
      end.
  
  -spec new_connection(inet:ip_address(), comm_server:tcp_port(),
  