Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Unified Diff: runtime/bin/socket_impl.dart

Issue 8726031: Change handling of accepting socket connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket.dart ('k') | samples/chat/http_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_impl.dart
diff --git a/runtime/bin/socket_impl.dart b/runtime/bin/socket_impl.dart
index b797d7de82464dbc7991557145aea80fe5dcde2e..9d70302eeb45f19d1a91c60788e26cc8e9d5f73d 100644
--- a/runtime/bin/socket_impl.dart
+++ b/runtime/bin/socket_impl.dart
@@ -240,12 +240,23 @@ class _ServerSocket extends _SocketBase implements ServerSocket {
bool _createBindListen(String bindAddress, int port, int backlog)
native "ServerSocket_CreateBindListen";
- void set connectionHandler(void callback()) {
- _setHandler(_IN_EVENT, callback);
+ void set connectionHandler(void callback(Socket connection)) {
+ _clientConnectionHandler = callback;
+ _setHandler(_IN_EVENT,
+ _clientConnectionHandler != null ? _connectionHandler : null);
+ }
+
+ void _connectionHandler() {
+ if (_id >= 0) {
+ _Socket socket = new _Socket._internal();
+ if (_accept(socket)) _clientConnectionHandler(socket);
+ }
}
bool _isListenSocket() => true;
bool _isPipe() => false;
+
+ var _clientConnectionHandler;
}
« no previous file with comments | « runtime/bin/socket.dart ('k') | samples/chat/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698