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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 }); | 106 }); |
107 | 107 |
108 Socket client = await Socket.connect(host, socket2.port); | 108 Socket client = await Socket.connect(host, socket2.port); |
109 await client.close(); | 109 await client.close(); |
110 await client.drain(); | 110 await client.drain(); |
111 | 111 |
112 asyncEnd(); | 112 asyncEnd(); |
113 } | 113 } |
114 | 114 |
115 Future<int> freeIPv4AndIPv6Port() async { | 115 Future<int> freeIPv4AndIPv6Port() async { |
116 var socket = await ServerSocket.bind(InternetAddress.ANY_IP_V6, 0, v6Only: fal
se); | 116 var socket = |
| 117 await ServerSocket.bind(InternetAddress.ANY_IP_V6, 0, v6Only: false); |
117 int port = socket.port; | 118 int port = socket.port; |
118 await socket.close(); | 119 await socket.close(); |
119 return port; | 120 return port; |
120 } | 121 } |
121 | 122 |
122 void main() async { | 123 main() async { |
123 asyncStart(); | 124 asyncStart(); |
124 await testBindDifferentAddresses(InternetAddress.ANY_IP_V6, | 125 await testBindDifferentAddresses(InternetAddress.ANY_IP_V6, |
125 InternetAddress.ANY_IP_V4, | 126 InternetAddress.ANY_IP_V4, |
126 true, | 127 true, |
127 false); | 128 false); |
128 await testBindDifferentAddresses(InternetAddress.ANY_IP_V4, | 129 await testBindDifferentAddresses(InternetAddress.ANY_IP_V4, |
129 InternetAddress.ANY_IP_V6, | 130 InternetAddress.ANY_IP_V6, |
130 false, | 131 false, |
131 true); | 132 true); |
132 | 133 |
133 for (var host in ['127.0.0.1', '::1']) { | 134 for (var host in ['127.0.0.1', '::1']) { |
134 testBindShared(host, false); | 135 testBindShared(host, false); |
135 testBindShared(host, true); | 136 testBindShared(host, true); |
136 | 137 |
137 negTestBindSharedMismatch(host, false); | 138 negTestBindSharedMismatch(host, false); |
138 negTestBindSharedMismatch(host, true); | 139 negTestBindSharedMismatch(host, true); |
139 | 140 |
140 negTestBindV6OnlyMismatch(host, true); | 141 negTestBindV6OnlyMismatch(host, true); |
141 negTestBindV6OnlyMismatch(host, false); | 142 negTestBindV6OnlyMismatch(host, false); |
142 | 143 |
143 testListenCloseListenClose(host); | 144 testListenCloseListenClose(host); |
144 } | 145 } |
145 asyncEnd(); | 146 asyncEnd(); |
146 } | 147 } |
OLD | NEW |