connect static method
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,
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,
);
}