anchor.diff:                             key_update_at := KeyUpdateAt,
                              log_level := LogLevel}},
        #data{connection_states = ConnectionStates, static = Static0} = StateData0) ->
  -    Monitor = erlang:monitor(process, Pid),
       StateData = 
           StateData0#data{connection_states = ConnectionStates#{current_write => WriteState},
                           static = Static0#static{connection_pid = Pid,
  -                                                connection_monitor = Monitor,
                                                   role = Role,
                                                   socket = Socket,
                                                   socket_options = SockOpts,
  
positive.code: %%% Internal functions
  %%%===================================================================
  
  handle_set_opts(
    From, Opts, #data{static = #static{socket_options = SockOpts} = Static} = StateData) ->
      {keep_state, StateData#data{static = Static#static{socket_options = set_opts(SockOpts, Opts)}},
       [{reply, From, ok}]}.
  
  handle_common(
    {call, From}, {set_opts, Opts},
    #data{static = #static{socket_options = SockOpts} = Static} = StateData) ->
      {keep_state, StateData#data{static = Static#static{socket_options = set_opts(SockOpts, Opts)}},
       [{reply, From, ok}]};
  handle_common(
    info, {'DOWN', Monitor, _, _, Reason},
    #data{static = #static{connection_monitor = Monitor,
                           dist_handle = Handle}} = StateData) when Handle =/= undefined ->
      {next_state, death_row, StateData,
       [{state_timeout, 5000, Reason}]};
  handle_common(
    info, {'DOWN', Monitor, _, _, _},
    #data{static = #static{connection_monitor = Monitor}} = StateData) ->
      {stop, normal, StateData};
  handle_common(info, Msg, #data{static = #static{log_level = Level}}) ->
      ssl_logger:log(info, Level, #{event => "TLS sender recived unexpected info", 
                                    reason => [{message, Msg}]}, ?LOCATION),
  
negative.code: %%--------------------------------------------------------------------
  death_row(state_timeout, Reason, _State) ->
      {stop, {shutdown, Reason}};
  death_row(info = Type, Msg, State) ->
      handle_common(Type, Msg, State);
  death_row(_Type, _Msg, _State) ->
      %% Waste all other events
      keep_state_and_data.
  