| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 | 5 |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 | 8 |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 asyncStart(); | 100 asyncStart(); |
| 101 | 101 |
| 102 // Connect with IPv4 source addesses. | 102 // Connect with IPv4 source addesses. |
| 103 for (var sourceAddress in ipV4SourceAddresses) { | 103 for (var sourceAddress in ipV4SourceAddresses) { |
| 104 if (!v6Only) { | 104 if (!v6Only) { |
| 105 var s = await connectFunction(InternetAddress.LOOPBACK_IP_V4, | 105 var s = await connectFunction(InternetAddress.LOOPBACK_IP_V4, |
| 106 server.port, | 106 server.port, |
| 107 sourceAddress: sourceAddress); | 107 sourceAddress: sourceAddress); |
| 108 closeDestroyFunction(s); | 108 closeDestroyFunction(s); |
| 109 } else { | 109 } else { |
| 110 // Cannot use an IPv6 source address to connect to IPv6 if | 110 // Cannot use an IPv4 source address to connect to IPv6 if |
| 111 // v6Only is specified. | 111 // v6Only is specified. |
| 112 await throws(() => connectFunction(InternetAddress.LOOPBACK_IP_V4, | 112 await throws(() => connectFunction(InternetAddress.LOOPBACK_IP_V6, |
| 113 server.port, | 113 server.port, |
| 114 sourceAddress: sourceAddress), | 114 sourceAddress: sourceAddress), |
| 115 (e) => e is SocketException); | 115 (e) => e is SocketException); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Connect with IPv6 source addesses. | 119 // Connect with IPv6 source addesses. |
| 120 for (var sourceAddress in ipV6SourceAddresses) { | 120 for (var sourceAddress in ipV6SourceAddresses) { |
| 121 if (bindAddress.type == InternetAddressType.IP_V6) { | 121 if (bindAddress.type == InternetAddressType.IP_V6) { |
| 122 var s = await connectFunction(InternetAddress.LOOPBACK_IP_V6, | 122 var s = await connectFunction(InternetAddress.LOOPBACK_IP_V6, |
| 123 server.port, | 123 server.port, |
| 124 sourceAddress: sourceAddress); | 124 sourceAddress: sourceAddress); |
| 125 closeDestroyFunction(s); | 125 closeDestroyFunction(s); |
| 126 } else { | 126 } else { |
| 127 // Cannot use an IPv6 source address to connect to IPv4. | 127 // Cannot use an IPv6 source address to connect to IPv4. |
| 128 await throws(() => connectFunction(InternetAddress.LOOPBACK_IP_V6, | 128 await throws(() => connectFunction(InternetAddress.LOOPBACK_IP_V4, |
| 129 server.port, | 129 server.port, |
| 130 sourceAddress: sourceAddress), | 130 sourceAddress: sourceAddress), |
| 131 (e) => e is SocketException); | 131 (e) => e is SocketException); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 await allConnected.future; | 135 await allConnected.future; |
| 136 await server.close(); | 136 await server.close(); |
| 137 asyncEnd(); | 137 asyncEnd(); |
| 138 } | 138 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 167 await testConnect( | 167 await testConnect( |
| 168 InternetAddress.ANY_IP_V6, true, RawSocket.connect, (s) => s.close()); | 168 InternetAddress.ANY_IP_V6, true, RawSocket.connect, (s) => s.close()); |
| 169 }); | 169 }); |
| 170 await retry(() async { | 170 await retry(() async { |
| 171 await testConnect( | 171 await testConnect( |
| 172 InternetAddress.ANY_IP_V6, true, Socket.connect, (s) => s.destroy()); | 172 InternetAddress.ANY_IP_V6, true, Socket.connect, (s) => s.destroy()); |
| 173 }); | 173 }); |
| 174 | 174 |
| 175 asyncEnd(); | 175 asyncEnd(); |
| 176 } | 176 } |
| OLD | NEW |