close method

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

void close({bool closeExternalSocket = false}) {
  if (_closed) {
    return;
  }

  for (final connection in _connections.values) {
    connection.close(closedByClient: true);
  }

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

  _closed = true;
}