| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 /** | 206 /** |
| 207 * Closes the socket. | 207 * Closes the socket. |
| 208 */ | 208 */ |
| 209 void close() { | 209 void close() { |
| 210 _closed = true; | 210 _closed = true; |
| 211 _socket.close(); | 211 _socket.close(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void _onData(RawSocket connection) { | 214 void _onData(RawSocket connection) { |
| 215 var remotePort; |
| 216 try { |
| 217 remotePort = connection.remotePort; |
| 218 } catch (e) { |
| 219 // If connection is already closed, remotePort throws an exception. |
| 220 // Do nothing - connection is closed. |
| 221 return; |
| 222 } |
| 215 _RawSecureSocket.connect( | 223 _RawSecureSocket.connect( |
| 216 connection.address, | 224 connection.address, |
| 217 connection.remotePort, | 225 remotePort, |
| 218 certificateName, | 226 certificateName, |
| 219 is_server: true, | 227 is_server: true, |
| 220 socket: connection, | 228 socket: connection, |
| 221 requestClientCertificate: requestClientCertificate, | 229 requestClientCertificate: requestClientCertificate, |
| 222 requireClientCertificate: requireClientCertificate) | 230 requireClientCertificate: requireClientCertificate) |
| 223 .then((RawSecureSocket secureConnection) { | 231 .then((RawSecureSocket secureConnection) { |
| 224 if (_closed) { | 232 if (_closed) { |
| 225 secureConnection.close(); | 233 secureConnection.close(); |
| 226 } else { | 234 } else { |
| 227 _controller.add(secureConnection); | 235 _controller.add(secureConnection); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 254 _subscription = _socket.listen(_onData, | 262 _subscription = _socket.listen(_onData, |
| 255 onDone: _onDone, | 263 onDone: _onDone, |
| 256 onError: _onError); | 264 onError: _onError); |
| 257 } else { | 265 } else { |
| 258 close(); | 266 close(); |
| 259 } | 267 } |
| 260 } | 268 } |
| 261 } | 269 } |
| 262 | 270 |
| 263 | 271 |
| OLD | NEW |