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 "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
11 import "dart:async"; | 11 import "dart:async"; |
12 import "dart:io"; | 12 import "dart:io"; |
13 import "dart:isolate"; | 13 import "dart:isolate"; |
14 | 14 |
| 15 const SERVER_ADDRESS = "127.0.0.1"; |
15 const HOST_NAME = "localhost"; | 16 const HOST_NAME = "localhost"; |
16 const CERTIFICATE = "localhost_cert"; | 17 const CERTIFICATE = "localhost_cert"; |
17 | 18 |
18 // This test creates a server and a client connects. After connecting | 19 // This test creates a server and a client connects. After connecting |
19 // and an optional initial handshake the connection is secured by | 20 // and an optional initial handshake the connection is secured by |
20 // upgrading to a secure connection The client then writes and the | 21 // upgrading to a secure connection The client then writes and the |
21 // server echos. When the server has finished its echo it | 22 // server echos. When the server has finished its echo it |
22 // half-closes. When the client gets the close event is closes fully. | 23 // half-closes. When the client gets the close event is closes fully. |
23 // | 24 // |
24 // The test can be run in different configurations based on | 25 // The test can be run in different configurations based on |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 }); | 188 }); |
188 }); | 189 }); |
189 } | 190 } |
190 }); | 191 }); |
191 | 192 |
192 connectClient(server.port).then(runClient).then((socket) { | 193 connectClient(server.port).then(runClient).then((socket) { |
193 port.close(); | 194 port.close(); |
194 }); | 195 }); |
195 } | 196 } |
196 | 197 |
197 ServerSocket.bind(HOST_NAME, 0, 5).then(serverReady); | 198 ServerSocket.bind(SERVER_ADDRESS, 0, 5).then(serverReady); |
198 } | 199 } |
199 | 200 |
200 main() { | 201 main() { |
201 Path scriptDir = new Path(new Options().script).directoryPath; | 202 Path scriptDir = new Path(new Options().script).directoryPath; |
202 Path certificateDatabase = scriptDir.append('pkcert'); | 203 Path certificateDatabase = scriptDir.append('pkcert'); |
203 SecureSocket.initialize(database: certificateDatabase.toNativePath(), | 204 SecureSocket.initialize(database: certificateDatabase.toNativePath(), |
204 password: 'dartdart', | 205 password: 'dartdart', |
205 useBuiltinRoots: false); | 206 useBuiltinRoots: false); |
206 test(false); | 207 test(false); |
207 test(true); | 208 test(true); |
208 test(true, true); | 209 test(true, true); |
209 } | 210 } |
OLD | NEW |