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 "dart:io"; | 9 import "dart:io"; |
10 import "dart:isolate"; | 10 import "dart:isolate"; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class TestServer extends TestingServer { | 73 class TestServer extends TestingServer { |
74 | 74 |
75 void onConnection(Socket connection) { | 75 void onConnection(Socket connection) { |
76 Socket _client; | 76 Socket _client; |
77 | 77 |
78 void closeHandler() { | 78 void closeHandler() { |
79 connection.close(); | 79 connection.close(); |
80 } | 80 } |
81 | 81 |
82 void errorHandler(e) { | 82 void errorHandler(e) { |
83 print("Socket error $e"); | 83 String msg = "Socket error $e"; |
| 84 var trace = getAttachedStackTrace(e); |
| 85 if (trace != null) msg += "\nStackTrace: $trace"; |
| 86 print(msg); |
84 connection.close(); | 87 connection.close(); |
85 } | 88 } |
86 | 89 |
87 _connections++; | 90 _connections++; |
88 connection.listen( | 91 connection.listen( |
89 (data) {}, | 92 (data) {}, |
90 onDone: closeHandler, | 93 onDone: closeHandler, |
91 onError: errorHandler); | 94 onError: errorHandler); |
92 } | 95 } |
93 | 96 |
94 int _connections = 0; | 97 int _connections = 0; |
95 } | 98 } |
96 | 99 |
97 main() { | 100 main() { |
98 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); | 101 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); |
99 } | 102 } |
OLD | NEW |