W3cubDocs

/Dart 2

startConnect method

Future<ConnectionTask<RawSecureSocket>> startConnect (dynamic host, int port, { SecurityContext context, bool onBadCertificate(X509Certificate certificate), List<String> supportedProtocols })
override

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

Implementation

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

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