| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test creating a large number of socket connections. | 5 // Test creating a large number of socket connections. |
| 6 library ServerTest; | 6 library ServerTest; |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 import "dart:async"; | 10 import "dart:async"; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 class TestServer extends TestingServer { | 75 class TestServer extends TestingServer { |
| 76 | 76 |
| 77 void onConnection(Socket connection) { | 77 void onConnection(Socket connection) { |
| 78 Socket _client; | 78 Socket _client; |
| 79 | 79 |
| 80 void closeHandler() { | 80 void closeHandler() { |
| 81 connection.close(); | 81 connection.close(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void errorHandler(e) { | 84 void errorHandler(e, trace) { |
| 85 String msg = "Socket error $e"; | 85 String msg = "Socket error $e"; |
| 86 var trace = getAttachedStackTrace(e); | |
| 87 if (trace != null) msg += "\nStackTrace: $trace"; | 86 if (trace != null) msg += "\nStackTrace: $trace"; |
| 88 print(msg); | 87 print(msg); |
| 89 connection.close(); | 88 connection.close(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 _connections++; | 91 _connections++; |
| 93 connection.listen( | 92 connection.listen( |
| 94 (data) {}, | 93 (data) {}, |
| 95 onDone: closeHandler, | 94 onDone: closeHandler, |
| 96 onError: errorHandler); | 95 onError: errorHandler); |
| 97 } | 96 } |
| 98 | 97 |
| 99 int _connections = 0; | 98 int _connections = 0; |
| 100 } | 99 } |
| 101 | 100 |
| 102 main() { | 101 main() { |
| 103 asyncStart(); | 102 asyncStart(); |
| 104 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); | 103 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); |
| 105 } | 104 } |
| OLD | NEW |