| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The [SecureServerSocket] is a server socket, providing a stream of high-level | 8 * The [SecureServerSocket] is a server socket, providing a stream of high-level |
| 9 * [Socket]s. | 9 * [Socket]s. |
| 10 * | 10 * |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 onDone: onDone, | 88 onDone: onDone, |
| 89 cancelOnError: cancelOnError); | 89 cancelOnError: cancelOnError); |
| 90 } | 90 } |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Returns the port used by this socket. | 93 * Returns the port used by this socket. |
| 94 */ | 94 */ |
| 95 int get port => _socket.port; | 95 int get port => _socket.port; |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Closes the socket. | 98 * Closes the socket. The returned future completes when the socket |
| 99 * is fully closed and is no longer bound. |
| 99 */ | 100 */ |
| 100 void close() => _socket.close(); | 101 Future<SecureServerSocket> close() => _socket.close().then((_) => this); |
| 101 } | 102 } |
| 102 | 103 |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * The RawSecureServerSocket is a server socket, providing a stream of low-level | 106 * The RawSecureServerSocket is a server socket, providing a stream of low-level |
| 106 * [RawSecureSocket]s. | 107 * [RawSecureSocket]s. |
| 107 * | 108 * |
| 108 * See [RawSecureSocket] for more info. | 109 * See [RawSecureSocket] for more info. |
| 109 */ | 110 */ |
| 110 class RawSecureServerSocket extends Stream<RawSecureSocket> { | 111 class RawSecureServerSocket extends Stream<RawSecureSocket> { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 onDone: onDone, | 198 onDone: onDone, |
| 198 cancelOnError: cancelOnError); | 199 cancelOnError: cancelOnError); |
| 199 } | 200 } |
| 200 | 201 |
| 201 /** | 202 /** |
| 202 * Returns the port used by this socket. | 203 * Returns the port used by this socket. |
| 203 */ | 204 */ |
| 204 int get port => _socket.port; | 205 int get port => _socket.port; |
| 205 | 206 |
| 206 /** | 207 /** |
| 207 * Closes the socket. | 208 * Closes the socket. The returned future completes when the socket |
| 209 * is fully closed and is no longer bound. |
| 208 */ | 210 */ |
| 209 void close() { | 211 Future<RawSecureServerSocket> close() { |
| 210 _closed = true; | 212 _closed = true; |
| 211 _socket.close(); | 213 return _socket.close().then((_) => this); |
| 212 } | 214 } |
| 213 | 215 |
| 214 void _onData(RawSocket connection) { | 216 void _onData(RawSocket connection) { |
| 215 var remotePort; | 217 var remotePort; |
| 216 try { | 218 try { |
| 217 remotePort = connection.remotePort; | 219 remotePort = connection.remotePort; |
| 218 } catch (e) { | 220 } catch (e) { |
| 219 // If connection is already closed, remotePort throws an exception. | 221 // If connection is already closed, remotePort throws an exception. |
| 220 // Do nothing - connection is closed. | 222 // Do nothing - connection is closed. |
| 221 return; | 223 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 _subscription = _socket.listen(_onData, | 264 _subscription = _socket.listen(_onData, |
| 263 onDone: _onDone, | 265 onDone: _onDone, |
| 264 onError: _onError); | 266 onError: _onError); |
| 265 } else { | 267 } else { |
| 266 close(); | 268 close(); |
| 267 } | 269 } |
| 268 } | 270 } |
| 269 } | 271 } |
| 270 | 272 |
| 271 | 273 |
| OLD | NEW |