| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Echo server test program to test socket streams. | 5 // Echo server test program to test socket streams. |
| 6 // | 6 // |
| 7 // VMOptions= | 7 // VMOptions= |
| 8 // VMOptions=--short_socket_read | 8 // VMOptions=--short_socket_read |
| 9 // VMOptions=--short_socket_write | 9 // VMOptions=--short_socket_write |
| 10 // VMOptions=--short_socket_read --short_socket_write | 10 // VMOptions=--short_socket_read --short_socket_write |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (_messages % 2 == 0) data = new List<int>(MSGSIZE); | 88 if (_messages % 2 == 0) data = new List<int>(MSGSIZE); |
| 89 inputStream.dataHandler = dataReceived; | 89 inputStream.dataHandler = dataReceived; |
| 90 } | 90 } |
| 91 | 91 |
| 92 _socket.closeHandler = closeHandler; | 92 _socket.closeHandler = closeHandler; |
| 93 _socket.errorHandler = errorHandler; | 93 _socket.errorHandler = errorHandler; |
| 94 stream.write(_buffer); | 94 |
| 95 // Test both write and writeFrom in different forms. |
| 96 switch (_messages % 2) { |
| 97 case 0: |
| 98 stream.write(_buffer); |
| 99 break; |
| 100 case 1: |
| 101 stream.write(_buffer, false); |
| 102 break; |
| 103 case 2: |
| 104 stream.writeFrom(_buffer); |
| 105 break; |
| 106 case 3: |
| 107 stream.writeFrom(_buffer, len: _buffer.length ~/ 2); |
| 108 stream.writeFrom(_buffer, _buffer.length ~/ 2); |
| 109 break; |
| 110 } |
| 95 stream.close(); | 111 stream.close(); |
| 96 dataSent(); | 112 dataSent(); |
| 97 } | 113 } |
| 98 | 114 |
| 99 _socket = new Socket(EchoServer.HOST, _port); | 115 _socket = new Socket(EchoServer.HOST, _port); |
| 100 if (_socket !== null) { | 116 if (_socket !== null) { |
| 101 _socket.connectHandler = connectHandler; | 117 _socket.connectHandler = connectHandler; |
| 102 } else { | 118 } else { |
| 103 Expect.fail("socket creation failed"); | 119 Expect.fail("socket creation failed"); |
| 104 } | 120 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 198 } |
| 183 }); | 199 }); |
| 184 } | 200 } |
| 185 | 201 |
| 186 ServerSocket _server; | 202 ServerSocket _server; |
| 187 } | 203 } |
| 188 | 204 |
| 189 main() { | 205 main() { |
| 190 EchoServerStreamTest.testMain(); | 206 EchoServerStreamTest.testMain(); |
| 191 } | 207 } |
| OLD | NEW |