anchor.diff:  socket(Conn) ->
       Conn#connection.socket.
   
  -%% Internal
  +%% @private
   do_connect(Address, Port, Options, Timeout, Transport, Control) ->
      case Transport:connect(Address, Port, Options, Timeout) of
          {ok, Socket} ->
  
positive.code: -record(connection, {
            socket :: gen_tcp:socket() | ssl:sslsocket(),
            transport :: gen_tcp | ssl,
            control :: inet | ssl
           }).
  
  -type connection() :: #connection{}.
  -export_type([connection/0]).
  
  
  %% @doc Wraps a TCP socket with the appropriate information for
  %% transceiving on and controlling the socket later. If TLS/SSL is
  
negative.code:            Error
     end.
  
  %% @private
  tls_enabled() ->
      partisan_config:get(tls).
  
  %% @private
  tls_options() ->
      partisan_config:get(tls_options).
  
  %% @private
  send(Transport, Socket, Data) ->
      %% Update last transmission time.
      put(last_transmission_time, erlang:monotonic_time(millisecond)),
  
      %% Transmit the data on the socket.
      Transport:send(Socket, Data).
  
  %% Determine if we should transmit:
  %%
  %% If theré's another message in the queue, we can skip 
  %% sending this message.  However, if the arrival rate of 
  %% messages is too high, we risk starvation where
  %% we may never send.  Therefore, we must force a transmission 
  %% after a given period with no transmissions.
  %%
  %% @private
  monotonic_should_send(MessageQueueLen, LastTransmissionTime) ->
      case length(MessageQueueLen) > 0 of
          true ->
              NowTime = erlang:monotonic_time(millisecond),
              Diff = abs(NowTime - LastTransmissionTime),
  
              SendWindow = partisan_config:get(send_window, 1000),
  
              case Diff > SendWindow of
                  true ->
                      true;
                  false ->
                      false
              end;
          false ->
              true
      end.