Index: sdk/lib/io/secure_socket.dart |
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart |
index 7f2e8cccfb6a621b12da4f3288750b2bc53d08a0..096318b72038ee852704cddcddb2a6f5e4d37fd2 100644 |
--- a/sdk/lib/io/secure_socket.dart |
+++ b/sdk/lib/io/secure_socket.dart |
@@ -33,16 +33,25 @@ abstract class SecureSocket implements Socket { |
* order of preference) to use during the ALPN protocol negogiation with the |
* server. Example values are "http/1.1" or "h2". The selected protocol |
* can be obtained via [SecureSocket.selectedProtocol]. |
+ * |
+ * The argument [timeout] is used to specify the maximum allowed time to wait |
+ * for a connection to be established. If [timeout] is longer than the system |
+ * level timeout duration, a timeout may occur sooner than specified in |
+ * [timeout]. On timeout, a [SocketException] is thrown and all ongoing |
+ * connection attempts to [host] are cancelled. |
+ |
*/ |
static Future<SecureSocket> connect(host, int port, |
{SecurityContext context, |
bool onBadCertificate(X509Certificate certificate), |
- List<String> supportedProtocols}) { |
+ List<String> supportedProtocols, |
+ Duration timeout}) { |
return RawSecureSocket |
.connect(host, port, |
context: context, |
onBadCertificate: onBadCertificate, |
- supportedProtocols: supportedProtocols) |
+ supportedProtocols: supportedProtocols, |
+ timeout: timeout) |
.then((rawSocket) => new SecureSocket._(rawSocket)); |
} |
@@ -194,10 +203,11 @@ abstract class RawSecureSocket implements RawSocket { |
static Future<RawSecureSocket> connect(host, int port, |
{SecurityContext context, |
bool onBadCertificate(X509Certificate certificate), |
- List<String> supportedProtocols}) { |
+ List<String> supportedProtocols, |
+ Duration timeout}) { |
_RawSecureSocket._verifyFields( |
host, port, false, false, false, onBadCertificate); |
- return RawSocket.connect(host, port).then((socket) { |
+ return RawSocket.connect(host, port, timeout: timeout).then((socket) { |
return secure(socket, |
context: context, |
onBadCertificate: onBadCertificate, |