Try IPv6 and switch to IPv4 if it doesn't work (#89)
Gives a broader support for test platforms without hardcoding.
diff --git a/test/io_server_test.dart b/test/io_server_test.dart
index e799774..f29e31b 100644
--- a/test/io_server_test.dart
+++ b/test/io_server_test.dart
@@ -14,12 +14,14 @@
import 'test_util.dart';
void main() {
- var server;
+ IOServer server;
+
setUp(() async {
- var address = Platform.environment.containsKey('TRAVIS')
- ? InternetAddress.LOOPBACK_IP_V4
- : InternetAddress.LOOPBACK_IP_V6;
- server = await IOServer.bind(address, 0);
+ try {
+ server = await IOServer.bind(InternetAddress.LOOPBACK_IP_V6, 0);
+ } on SocketException catch (_) {
+ server = await IOServer.bind(InternetAddress.LOOPBACK_IP_V4, 0);
+ }
});
tearDown(() => server.close());