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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 void connectHandler() { | 97 void connectHandler() { |
98 _socket.onData = dataHandler; | 98 _socket.onData = dataHandler; |
99 _socket.onClosed = closeHandler; | 99 _socket.onClosed = closeHandler; |
100 _socket.onError = errorHandler; | 100 _socket.onError = errorHandler; |
101 | 101 |
102 void writeHello() { | 102 void writeHello() { |
103 int bytesWritten = 0; | 103 int bytesWritten = 0; |
104 while (bytesWritten != 5) { | 104 while (bytesWritten != 5) { |
105 bytesWritten += _socket.writeList("Hello".charCodes(), | 105 bytesWritten += _socket.writeList("Hello".charCodes, |
106 bytesWritten, | 106 bytesWritten, |
107 5 - bytesWritten); | 107 5 - bytesWritten); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 _iterations++; | 111 _iterations++; |
112 switch (_mode) { | 112 switch (_mode) { |
113 case 0: | 113 case 0: |
114 _socket.close(); | 114 _socket.close(); |
115 proceed(); | 115 proceed(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 List<int> b = new List<int>(5); | 222 List<int> b = new List<int>(5); |
223 data.readBytes += connection.readList(b, 0, 5); | 223 data.readBytes += connection.readList(b, 0, 5); |
224 if (data.readBytes == 5) { | 224 if (data.readBytes == 5) { |
225 whenFiveBytes(); | 225 whenFiveBytes(); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 void writeHello() { | 229 void writeHello() { |
230 int bytesWritten = 0; | 230 int bytesWritten = 0; |
231 while (bytesWritten != 5) { | 231 while (bytesWritten != 5) { |
232 bytesWritten += connection.writeList("Hello".charCodes(), | 232 bytesWritten += connection.writeList("Hello".charCodes, |
233 bytesWritten, | 233 bytesWritten, |
234 5 - bytesWritten); | 234 5 - bytesWritten); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 void dataHandler() { | 238 void dataHandler() { |
239 switch (_mode) { | 239 switch (_mode) { |
240 case 0: | 240 case 0: |
241 Expect.fail("No data expected"); | 241 Expect.fail("No data expected"); |
242 break; | 242 break; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 var tests = 7; | 380 var tests = 7; |
381 var port = new ReceivePort(); | 381 var port = new ReceivePort(); |
382 var completed = 0; | 382 var completed = 0; |
383 port.receive((message, ignore) { | 383 port.receive((message, ignore) { |
384 if (++completed == tests) port.close(); | 384 if (++completed == tests) port.close(); |
385 }); | 385 }); |
386 for (var i = 0; i < tests; i++) { | 386 for (var i = 0; i < tests; i++) { |
387 new SocketClose.start(i, port.toSendPort()); | 387 new SocketClose.start(i, port.toSendPort()); |
388 } | 388 } |
389 } | 389 } |
OLD | NEW |