| 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 // 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 // Test socket close events. | 10 // Test socket close events. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 _socket.outputStream.onNoPendingWrites = () { | 135 _socket.outputStream.onNoPendingWrites = () { |
| 136 _socket.outputStream.close(); | 136 _socket.outputStream.close(); |
| 137 }; | 137 }; |
| 138 break; | 138 break; |
| 139 default: | 139 default: |
| 140 Expect.fail("Unknown test mode"); | 140 Expect.fail("Unknown test mode"); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 _socket = new Socket(SocketCloseServer.HOST, _port); | 144 _socket = new Socket(SocketCloseServer.HOST, _port); |
| 145 Expect.equals(true, _socket !== null); | 145 Expect.equals(true, _socket != null); |
| 146 _socket.onConnect = connectHandler; | 146 _socket.onConnect = connectHandler; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void initialize() { | 149 void initialize() { |
| 150 _receivePort.receive((var message, SendPort replyTo) { | 150 _receivePort.receive((var message, SendPort replyTo) { |
| 151 _port = message; | 151 _port = message; |
| 152 proceed(); | 152 proceed(); |
| 153 }); | 153 }); |
| 154 _sendPort.send(_mode, _receivePort.toSendPort()); | 154 _sendPort.send(_mode, _receivePort.toSendPort()); |
| 155 } | 155 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 void dispatch(message, replyTo) { | 362 void dispatch(message, replyTo) { |
| 363 _donePort = replyTo; | 363 _donePort = replyTo; |
| 364 if (message != SERVERSHUTDOWN) { | 364 if (message != SERVERSHUTDOWN) { |
| 365 _readBytes = 0; | 365 _readBytes = 0; |
| 366 _errorEvents = 0; | 366 _errorEvents = 0; |
| 367 _dataEvents = 0; | 367 _dataEvents = 0; |
| 368 _closeEvents = 0; | 368 _closeEvents = 0; |
| 369 _iterations = 0; | 369 _iterations = 0; |
| 370 _mode = message; | 370 _mode = message; |
| 371 _server = new ServerSocket(HOST, 0, 10); | 371 _server = new ServerSocket(HOST, 0, 10); |
| 372 Expect.equals(true, _server !== null); | 372 Expect.equals(true, _server != null); |
| 373 _server.onConnection = (connection) { | 373 _server.onConnection = (connection) { |
| 374 var data = new ConnectionData(connection); | 374 var data = new ConnectionData(connection); |
| 375 connectionHandler(data); | 375 connectionHandler(data); |
| 376 }; | 376 }; |
| 377 _server.onError = errorHandlerServer; | 377 _server.onError = errorHandlerServer; |
| 378 replyTo.send(_server.port, null); | 378 replyTo.send(_server.port, null); |
| 379 } else { | 379 } else { |
| 380 new Timer(0, waitForResult); | 380 new Timer(0, waitForResult); |
| 381 } | 381 } |
| 382 } | 382 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 408 var tests = 9; | 408 var tests = 9; |
| 409 var port = new ReceivePort(); | 409 var port = new ReceivePort(); |
| 410 var completed = 0; | 410 var completed = 0; |
| 411 port.receive((message, ignore) { | 411 port.receive((message, ignore) { |
| 412 if (++completed == tests) port.close(); | 412 if (++completed == tests) port.close(); |
| 413 }); | 413 }); |
| 414 for (var i = 0; i < tests; i++) { | 414 for (var i = 0; i < tests; i++) { |
| 415 new SocketClose.start(i, port.toSendPort()); | 415 new SocketClose.start(i, port.toSendPort()); |
| 416 } | 416 } |
| 417 } | 417 } |
| OLD | NEW |