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