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 // 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 stream.write(_buffer); | 88 stream.write(_buffer); |
89 break; | 89 break; |
90 case 1: | 90 case 1: |
91 stream.write(_buffer, false); | 91 stream.write(_buffer, false); |
92 break; | 92 break; |
93 case 2: | 93 case 2: |
94 stream.writeFrom(_buffer); | 94 stream.writeFrom(_buffer); |
95 break; | 95 break; |
96 case 3: | 96 case 3: |
97 Expect.equals(0, _buffer.length % 2); | 97 Expect.equals(0, _buffer.length % 2); |
98 stream.writeFrom(_buffer, len: _buffer.length ~/ 2); | 98 stream.writeFrom(_buffer, 0, _buffer.length ~/ 2); |
99 stream.writeFrom(_buffer, _buffer.length ~/ 2); | 99 stream.writeFrom(_buffer, _buffer.length ~/ 2); |
100 break; | 100 break; |
101 } | 101 } |
102 stream.close(); | 102 stream.close(); |
103 dataSent(); | 103 dataSent(); |
104 } | 104 } |
105 | 105 |
106 _socket = new Socket(TestingServer.HOST, _port); | 106 _socket = new Socket(TestingServer.HOST, _port); |
107 if (_socket !== null) { | 107 if (_socket !== null) { |
108 _socket.onConnect = connectHandler; | 108 _socket.onConnect = connectHandler; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 inputStream = connection.inputStream; | 172 inputStream = connection.inputStream; |
173 inputStream.onData = dataReceived; | 173 inputStream.onData = dataReceived; |
174 connection.onError = errorHandler; | 174 connection.onError = errorHandler; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 main() { | 178 main() { |
179 EchoServerGame echoServerGame = new EchoServerGame.start(); | 179 EchoServerGame echoServerGame = new EchoServerGame.start(); |
180 } | 180 } |
OLD | NEW |