OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:async'; | |
6 import 'dart:io'; | |
7 | |
8 import 'package:async_helper/async_helper.dart'; | |
9 | |
10 | |
11 testBothListen() { | |
12 asyncStart(); | |
13 ServerSocket.bind('127.0.0.1', 0).then((mainServer) { | |
14 mainServer.reference.create().then((refServer) { | |
15 refServer.listen((_) {}); | |
16 mainServer.listen((_) {}); | |
17 Timer.run(() { | |
18 mainServer.close(); | |
19 refServer.close(); | |
20 asyncEnd(); | |
21 }); | |
22 }); | |
23 }); | |
24 } | |
25 | |
26 testRefServerListen() { | |
27 asyncStart(); | |
28 ServerSocket.bind('127.0.0.1', 0).then((mainServer) { | |
29 mainServer.reference.create().then((refServer) { | |
30 refServer.listen((_) {}); | |
31 Timer.run(() { | |
32 mainServer.close(); | |
33 refServer.close(); | |
34 asyncEnd(); | |
35 }); | |
36 }); | |
37 }); | |
38 } | |
39 | |
40 testMainServerListen() { | |
41 asyncStart(); | |
42 ServerSocket.bind('127.0.0.1', 0).then((mainServer) { | |
43 mainServer.reference.create().then((refServer) { | |
44 mainServer.listen((_) {}); | |
45 Timer.run(() { | |
46 mainServer.close(); | |
47 refServer.close(); | |
48 asyncEnd(); | |
49 }); | |
50 }); | |
51 }); | |
52 } | |
53 | |
54 testNoneListen() { | |
55 asyncStart(); | |
56 ServerSocket.bind('127.0.0.1', 0).then((mainServer) { | |
57 mainServer.reference.create().then((refServer) { | |
58 Timer.run(() { | |
59 mainServer.close(); | |
60 refServer.close(); | |
61 asyncEnd(); | |
62 }); | |
63 }); | |
64 }); | |
65 } | |
66 | |
67 main() { | |
68 testNoneListen(); | |
69 testMainServerListen(); | |
70 testRefServerListen(); | |
71 testBothListen(); | |
72 } | |
73 | |
OLD | NEW |