startConnect method

Future<ConnectionTask<SecureSocket>> startConnect (
  1. dynamic host,
  2. int port,
  3. {SecurityContext? context,
  4. bool onBadCertificate(
    1. X509Certificate certificate
    ),
  5. List<String>? supportedProtocols}
)
override

Like connect, but returns a Future that completes with a ConnectionTask that can be cancelled if the SecureSocket is no longer needed.

Implementation

static Future<ConnectionTask<SecureSocket>> startConnect(host, int port,
    {SecurityContext? context,
    bool onBadCertificate(X509Certificate certificate)?,
    List<String>? supportedProtocols}) {
  return RawSecureSocket.startConnect(host, port,
          context: context,
          onBadCertificate: onBadCertificate,
          supportedProtocols: supportedProtocols)
      .then((rawState) {
    Future<SecureSocket> socket =
        rawState.socket.then((rawSocket) => new SecureSocket._(rawSocket));
    return new ConnectionTask<SecureSocket>._(socket, rawState._onCancel);
  });
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-io/SecureSocket/startConnect.html