Unverified Commit 9be85b6b authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

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.
parent 96942bc7
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment