startConnect 静态方法
- dynamic host,
- int port,
- {SecurityContext? context,
- bool onBadCertificate(
- X509Certificate certificate
- void keyLog(
- String line
- List<
String> ? supportedProtocols}
override
类似于 connect,但返回一个 Future,它可以完成一个 ConnectionTask
,如果不再需要 RawSecureSocket,则可以取消此任务。
实现
static Future<ConnectionTask<RawSecureSocket>> startConnect(host, int port,
{SecurityContext? context,
bool onBadCertificate(X509Certificate certificate)?,
void keyLog(String line)?,
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,
keyLog: keyLog,
supportedProtocols: supportedProtocols);
});
return new ConnectionTask<RawSecureSocket>._(socket, rawState._onCancel);
});
}