connect static method

Future<PQSecureChannel> connect(
  1. Object host,
  2. int port, {
  3. required SigningPublicKey serverKey,
  4. required String serverId,
  5. String clientId = '',
  6. SigningKeyPair? clientIdentity,
  7. PostQuantumCryptoEngine? engine,
  8. PQSecureChannelOptions options = const PQSecureChannelOptions(),
  9. Duration? connectTimeout,
})

Opens a TCP connection to host:port and runs the client handshake (see PQSecureChannel.connect). connectTimeout bounds the TCP connect; options.handshakeTimeout bounds the handshake.

Throws PQSecureChannelException if the handshake fails, and the dart:io SocketException if the connection cannot be opened.

Implementation

static Future<PQSecureChannel> connect(
  Object host,
  int port, {
  required SigningPublicKey serverKey,
  required String serverId,
  String clientId = '',
  SigningKeyPair? clientIdentity,
  PostQuantumCryptoEngine? engine,
  PQSecureChannelOptions options = const PQSecureChannelOptions(),
  Duration? connectTimeout,
}) async {
  final socket = await Socket.connect(host, port, timeout: connectTimeout);
  if (!_prepare(socket)) {
    throw const PQSecureChannelException(
      'Connection closed by peer during the handshake',
    );
  }
  return PQSecureChannel.connect(
    socket,
    socket,
    serverKey: serverKey,
    serverId: serverId,
    clientId: clientId,
    clientIdentity: clientIdentity,
    engine: engine,
    options: options,
    destroy: socket.destroy,
  );
}