| 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 patch class RawServerSocket { | 5 patch class RawServerSocket { |
| 6 /* patch */ static Future<RawServerSocket> bind(address, | 6 /* patch */ static Future<RawServerSocket> bind(address, |
| 7 int port, | 7 int port, |
| 8 {int backlog: 0, | 8 {int backlog: 0, |
| 9 bool v6Only: false}) { | 9 bool v6Only: false}) { |
| 10 return _RawServerSocket.bind(address, port, backlog, v6Only); | 10 return _RawServerSocket.bind(address, port, backlog, v6Only); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // Don't call the in handler if there is no data available | 483 // Don't call the in handler if there is no data available |
| 484 // after all. | 484 // after all. |
| 485 if (i == READ_EVENT && | 485 if (i == READ_EVENT && |
| 486 typeFlags != TYPE_LISTENING_SOCKET && | 486 typeFlags != TYPE_LISTENING_SOCKET && |
| 487 available() == 0) { | 487 available() == 0) { |
| 488 continue; | 488 continue; |
| 489 } | 489 } |
| 490 if (i == ERROR_EVENT) { | 490 if (i == ERROR_EVENT) { |
| 491 reportError(nativeGetError(), ""); | 491 reportError(nativeGetError(), ""); |
| 492 } else if (!isClosed) { | 492 } else if (!isClosed) { |
| 493 handler(); | 493 // If the connection is closed right after it's accepted, there's a |
| 494 // chance the close-handler is not set. |
| 495 if (handler != null) handler(); |
| 494 } | 496 } |
| 495 } | 497 } |
| 496 } | 498 } |
| 497 if (isClosedRead && isClosedWrite) close(); | 499 if (isClosedRead && isClosedWrite) close(); |
| 498 canActivateEvents = true; | 500 canActivateEvents = true; |
| 499 activateHandlers(); | 501 activateHandlers(); |
| 500 } | 502 } |
| 501 | 503 |
| 502 void setHandlers({read, write, error, closed, destroyed}) { | 504 void setHandlers({read, write, error, closed, destroyed}) { |
| 503 eventHandlers[READ_EVENT] = read; | 505 eventHandlers[READ_EVENT] = read; |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 if (_detachReady != null) { | 1220 if (_detachReady != null) { |
| 1219 _detachReady.complete(null); | 1221 _detachReady.complete(null); |
| 1220 } else { | 1222 } else { |
| 1221 if (_raw != null) { | 1223 if (_raw != null) { |
| 1222 _raw.shutdown(SocketDirection.SEND); | 1224 _raw.shutdown(SocketDirection.SEND); |
| 1223 _disableWriteEvent(); | 1225 _disableWriteEvent(); |
| 1224 } | 1226 } |
| 1225 } | 1227 } |
| 1226 } | 1228 } |
| 1227 } | 1229 } |
| OLD | NEW |