| 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 // Tests socket exceptions. | 5 // Tests socket exceptions. |
| 6 | 6 |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 | 9 |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 ServerSocket.bind("127.0.0.1", 0).then((server) { | 200 ServerSocket.bind("127.0.0.1", 0).then((server) { |
| 201 var completer = new Completer(); | 201 var completer = new Completer(); |
| 202 server.listen((socket) { | 202 server.listen((socket) { |
| 203 completer.future.then((_) => socket.destroy()); | 203 completer.future.then((_) => socket.destroy()); |
| 204 }); | 204 }); |
| 205 Socket.connect("127.0.0.1", server.port).then((client) { | 205 Socket.connect("127.0.0.1", server.port).then((client) { |
| 206 const int SIZE = 1024 * 1024; | 206 const int SIZE = 1024 * 1024; |
| 207 int errors = 0; | 207 int errors = 0; |
| 208 client.add(new List.filled(SIZE, 0)); | 208 client.add(new List.filled(SIZE, 0)); |
| 209 client.close(); | 209 client.close(); |
| 210 client.done.catchError((error) { | 210 client.done |
| 211 server.close(); | 211 .catchError((_) {}) |
| 212 }); | 212 .whenComplete(() { |
| 213 server.close(); |
| 214 }); |
| 213 // Destroy other socket now. | 215 // Destroy other socket now. |
| 214 completer.complete(null); | 216 completer.complete(null); |
| 215 }); | 217 }); |
| 216 }); | 218 }); |
| 217 } | 219 } |
| 218 | 220 |
| 219 static void unknownHostTest() { | 221 static void unknownHostTest() { |
| 220 asyncStart(); | 222 asyncStart(); |
| 221 Socket.connect("hede.hule.hest", 1234) | 223 Socket.connect("hede.hule.hest", 1234) |
| 222 .then((socket) => Expect.fail("Connection completed")) | 224 .then((socket) => Expect.fail("Connection completed")) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 237 unknownHostTest(); | 239 unknownHostTest(); |
| 238 } | 240 } |
| 239 } | 241 } |
| 240 | 242 |
| 241 main() { | 243 main() { |
| 242 asyncStart(); | 244 asyncStart(); |
| 243 SocketExceptionTest.testMain(); | 245 SocketExceptionTest.testMain(); |
| 244 asyncEnd(); | 246 asyncEnd(); |
| 245 } | 247 } |
| 246 | 248 |
| OLD | NEW |