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 // VMOptions= | 5 // VMOptions= |
6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
9 | 9 |
10 library dart.io; | 10 library dart.io; |
11 | 11 |
12 import "package:expect/expect.dart"; | 12 import "package:expect/expect.dart"; |
13 import "dart:async"; | 13 import "dart:async"; |
14 import "dart:io"; | 14 import "dart:io"; |
15 import "dart:math"; | 15 import "dart:math"; |
16 | 16 |
17 part "../../../sdk/lib/io/crypto.dart"; | 17 part "../../../sdk/lib/io/crypto.dart"; |
18 | 18 |
19 | |
20 const String webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 19 const String webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
21 | 20 |
22 void testPing(int totalConnections) { | 21 void testPing(int totalConnections) { |
23 HttpServer.bind('localhost', 0).then((server) { | 22 HttpServer.bind('localhost', 0).then((server) { |
24 int closed = 0; | 23 int closed = 0; |
25 server.listen((request) { | 24 server.listen((request) { |
26 var response = request.response; | 25 var response = request.response; |
27 response.statusCode = HttpStatus.SWITCHING_PROTOCOLS; | 26 response.statusCode = HttpStatus.SWITCHING_PROTOCOLS; |
28 response.headers.set(HttpHeaders.CONNECTION, "upgrade"); | 27 response.headers.set(HttpHeaders.CONNECTION, "upgrade"); |
29 response.headers.set(HttpHeaders.UPGRADE, "websocket"); | 28 response.headers.set(HttpHeaders.UPGRADE, "websocket"); |
(...skipping 16 matching lines...) Expand all Loading... |
46 | 45 |
47 for (int i = 0; i < totalConnections; i++) { | 46 for (int i = 0; i < totalConnections; i++) { |
48 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) { | 47 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) { |
49 webSocket.pingInterval = const Duration(milliseconds: 100); | 48 webSocket.pingInterval = const Duration(milliseconds: 100); |
50 webSocket.drain(); | 49 webSocket.drain(); |
51 }); | 50 }); |
52 } | 51 } |
53 }); | 52 }); |
54 } | 53 } |
55 | 54 |
56 | |
57 void main() { | 55 void main() { |
58 testPing(10); | 56 testPing(10); |
59 } | 57 } |
OLD | NEW |