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 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 void main() { | 8 void main(List<String> arguments) { |
9 int port = int.parse(new Options().arguments.first); | 9 int port = int.parse(arguments.first); |
10 var client = new HttpClient(); | 10 var client = new HttpClient(); |
11 const MAX = 64; | 11 const MAX = 64; |
12 int count = 0; | 12 int count = 0; |
13 void run() { | 13 void run() { |
14 if (count++ == MAX) exit(0); | 14 if (count++ == MAX) exit(0); |
15 Socket.connect('127.0.0.1', port).then((socket) { | 15 Socket.connect('127.0.0.1', port).then((socket) { |
16 socket.write("POST / HTTP/1.1\r\n"); | 16 socket.write("POST / HTTP/1.1\r\n"); |
17 socket.write("Content-Length: 10\r\n"); | 17 socket.write("Content-Length: 10\r\n"); |
18 socket.write("\r\n"); | 18 socket.write("\r\n"); |
19 socket.write("LALALA"); | 19 socket.write("LALALA"); |
20 socket.destroy(); | 20 socket.destroy(); |
21 socket.listen(null, onDone: run); | 21 socket.listen(null, onDone: run); |
22 }); | 22 }); |
23 } | 23 } |
24 for (int i = 0; i < 4; i++) run(); | 24 for (int i = 0; i < 4; i++) run(); |
25 } | 25 } |
26 | |
OLD | NEW |