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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 Expect.equals(0, _buffer.length % 2); | 97 Expect.equals(0, _buffer.length % 2); |
98 stream.writeFrom(_buffer, 0, _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; |
109 } else { | 109 } else { |
110 Expect.fail("socket creation failed"); | 110 Expect.fail("socket creation failed"); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 void initialize() { | 114 void initialize() { |
115 _receivePort.receive((var message, SendPort replyTo) { | 115 _receivePort.receive((var message, SendPort replyTo) { |
116 _port = message; | 116 _port = message; |
117 sendData(); | 117 sendData(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 inputStream = connection.inputStream; | 171 inputStream = connection.inputStream; |
172 inputStream.onData = dataReceived; | 172 inputStream.onData = dataReceived; |
173 connection.onError = errorHandler; | 173 connection.onError = errorHandler; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 main() { | 177 main() { |
178 EchoServerGame echoServerGame = new EchoServerGame.start(); | 178 EchoServerGame echoServerGame = new EchoServerGame.start(); |
179 } | 179 } |
OLD | NEW |