| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.util.io; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 import 'dart:convert'; | 6 import 'dart:convert'; |
| 9 import 'dart:io'; | 7 import 'dart:io'; |
| 10 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 11 | 9 |
| 12 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| 13 import 'package:pub_semver/pub_semver.dart'; | 11 import 'package:pub_semver/pub_semver.dart'; |
| 14 | 12 |
| 15 import '../backend/operating_system.dart'; | 13 import '../backend/operating_system.dart'; |
| 16 import '../runner/application_exception.dart'; | 14 import '../runner/application_exception.dart'; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 /// | 173 /// |
| 176 /// This has a built-in race condition: another process may bind this port at | 174 /// This has a built-in race condition: another process may bind this port at |
| 177 /// any time after this call has returned. If at all possible, callers should | 175 /// any time after this call has returned. If at all possible, callers should |
| 178 /// use [getUnusedPort] instead. | 176 /// use [getUnusedPort] instead. |
| 179 Future<int> getUnsafeUnusedPort() async { | 177 Future<int> getUnsafeUnusedPort() async { |
| 180 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); | 178 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); |
| 181 var port = socket.port; | 179 var port = socket.port; |
| 182 await socket.close(); | 180 await socket.close(); |
| 183 return port; | 181 return port; |
| 184 } | 182 } |
| OLD | NEW |