forked from firka/flutter
Support IPv6-only hosts in vmservice_test.dart. (#12985)
If we fail to bind to IPv4 loopback, try IPv6. Some hosts only support IPv6, causing the test in vmservice_test.dart to fail, since it couldn't find an available port.
This commit is contained in:
@@ -61,7 +61,12 @@ class HostPortScanner extends PortScanner {
|
||||
|
||||
@override
|
||||
Future<int> findAvailablePort() async {
|
||||
final ServerSocket socket = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0);
|
||||
ServerSocket socket;
|
||||
try {
|
||||
socket = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0);
|
||||
} on SocketException {
|
||||
socket = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V6, 0, v6Only: true);
|
||||
}
|
||||
final int port = socket.port;
|
||||
await socket.close();
|
||||
return port;
|
||||
|
||||
Reference in New Issue
Block a user