close method

Future<void> close({
  1. bool closeExternalSocket = false,
})

Closes this DtlsClient.

RawDatagramSockets that have been passed in by the user are only closed if closeExternalSocket is set to true.

Implementation

Future<void> close({bool closeExternalSocket = false}) async {
  if (_closed) {
    return;
  }

  await _connectionCache.closeConnections();

  if (!_externalSocket || closeExternalSocket) {
    _socket.close();
  }

  _closed = true;
}