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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:async"; | 6 import "dart:async"; |
7 import "dart:io"; | 7 import "dart:io"; |
8 import "dart:isolate"; | 8 import "dart:isolate"; |
9 | 9 |
10 void sendData(List<int> data, int port) { | 10 void sendData(List<int> data, int port) { |
11 Socket.connect("127.0.0.1", port).then((socket) { | 11 Socket.connect("127.0.0.1", port).then((socket) { |
12 socket.listen((data) { | 12 socket.listen((data) { |
13 Expect.fail("No data response was expected"); | 13 Expect.fail("No data response was expected"); |
14 }); | 14 }); |
15 socket.writeBytes(data); | 15 socket.add(data); |
16 socket.close(); | 16 socket.close(); |
17 socket.done.then((_) { | 17 socket.done.then((_) { |
18 socket.destroy(); | 18 socket.destroy(); |
19 }); | 19 }); |
20 }); | 20 }); |
21 } | 21 } |
22 | 22 |
23 class EarlyCloseTest { | 23 class EarlyCloseTest { |
24 EarlyCloseTest(this.data, | 24 EarlyCloseTest(this.data, |
25 String this.exception, | 25 String this.exception, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 socket.done.catchError((_) {}); | 157 socket.done.catchError((_) {}); |
158 }); | 158 }); |
159 }); | 159 }); |
160 } | 160 } |
161 | 161 |
162 void main() { | 162 void main() { |
163 testEarlyClose1(); | 163 testEarlyClose1(); |
164 testEarlyClose2(); | 164 testEarlyClose2(); |
165 testEarlyClose3(); | 165 testEarlyClose3(); |
166 } | 166 } |
OLD | NEW |