| 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 | 6 |
| 7 #library("SocketManyConnectionsTest"); | |
| 8 #import("dart:io"); | 7 #import("dart:io"); |
| 9 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 10 #source("TestingServer.dart"); | 9 #source("TestingServer.dart"); |
| 11 | 10 |
| 12 final CONNECTIONS = 200; | 11 final CONNECTIONS = 200; |
| 13 | 12 |
| 14 class SocketManyConnectionsTest { | 13 class SocketManyConnectionsTest { |
| 15 | 14 |
| 16 SocketManyConnectionsTest.start() | 15 SocketManyConnectionsTest.start() |
| 17 : _receivePort = new ReceivePort(), | 16 : _receivePort = new ReceivePort(), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 60 |
| 62 int _port; | 61 int _port; |
| 63 ReceivePort _receivePort; | 62 ReceivePort _receivePort; |
| 64 SendPort _sendPort; | 63 SendPort _sendPort; |
| 65 List<Socket> _sockets; | 64 List<Socket> _sockets; |
| 66 int _connections; | 65 int _connections; |
| 67 } | 66 } |
| 68 | 67 |
| 69 class TestServer extends TestingServer { | 68 class TestServer extends TestingServer { |
| 70 | 69 |
| 71 void connectionHandler(Socket connection) { | 70 void onConnection(Socket connection) { |
| 72 Socket _client; | 71 Socket _client; |
| 73 | 72 |
| 74 void closeHandler() { | 73 void closeHandler() { |
| 75 connection.close(); | 74 connection.close(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void errorHandler() { | 77 void errorHandler() { |
| 79 print("Socket error"); | 78 print("Socket error"); |
| 80 connection.close(); | 79 connection.close(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 _connections++; | 82 _connections++; |
| 84 connection.onClosed = closeHandler; | 83 connection.onClosed = closeHandler; |
| 85 connection.onError = errorHandler; | 84 connection.onError = errorHandler; |
| 86 } | 85 } |
| 87 | 86 |
| 88 int _connections = 0; | 87 int _connections = 0; |
| 89 } | 88 } |
| 90 | 89 |
| 91 main() { | 90 main() { |
| 92 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); | 91 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); |
| 93 } | 92 } |
| OLD | NEW |