OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "dart:async"; | 10 import "dart:async"; |
(...skipping 26 matching lines...) Expand all Loading... |
37 bytesWritten += client.write( | 37 bytesWritten += client.write( |
38 dataToWrite, bytesWritten, dataToWrite.length - bytesWritten); | 38 dataToWrite, bytesWritten, dataToWrite.length - bytesWritten); |
39 if (bytesWritten < dataToWrite.length) { | 39 if (bytesWritten < dataToWrite.length) { |
40 client.writeEventsEnabled = true; | 40 client.writeEventsEnabled = true; |
41 } | 41 } |
42 if (bytesWritten == dataToWrite.length) { | 42 if (bytesWritten == dataToWrite.length) { |
43 client.shutdown(SocketDirection.SEND); | 43 client.shutdown(SocketDirection.SEND); |
44 } | 44 } |
45 break; | 45 break; |
46 case RawSocketEvent.READ_CLOSED: | 46 case RawSocketEvent.READ_CLOSED: |
47 dataToWrite = readChunks.reduce(<int>[], (list, x) { | 47 dataToWrite = readChunks.fold(<int>[], (list, x) { |
48 list.addAll(x); | 48 list.addAll(x); |
49 return list; | 49 return list; |
50 }); | 50 }); |
51 client.writeEventsEnabled = true; | 51 client.writeEventsEnabled = true; |
52 break; | 52 break; |
53 } | 53 } |
54 }); | 54 }); |
55 }); | 55 }); |
56 return server; | 56 return server; |
57 }); | 57 }); |
(...skipping 24 matching lines...) Expand all Loading... |
82 Path certificateDatabase = scriptDir.append('pkcert'); | 82 Path certificateDatabase = scriptDir.append('pkcert'); |
83 SecureSocket.initialize(database: certificateDatabase.toNativePath(), | 83 SecureSocket.initialize(database: certificateDatabase.toNativePath(), |
84 password: 'dartdart'); | 84 password: 'dartdart'); |
85 | 85 |
86 startEchoServer() | 86 startEchoServer() |
87 .then(testClient) | 87 .then(testClient) |
88 .then((server) { | 88 .then((server) { |
89 server.close(); | 89 server.close(); |
90 }); | 90 }); |
91 } | 91 } |
OLD | NEW |