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 | 5 |
6 class _SocketBase { | 6 class _SocketBase { |
7 // Bit flags used when communicating between the eventhandler and | 7 // Bit flags used when communicating between the eventhandler and |
8 // dart code. The EVENT flags are used to indicate events of | 8 // dart code. The EVENT flags are used to indicate events of |
9 // interest when sending a message from dart code to the | 9 // interest when sending a message from dart code to the |
10 // eventhandler. When receiving a message from the eventhandler the | 10 // eventhandler. When receiving a message from the eventhandler the |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 _setHandler(_IN_EVENT, | 285 _setHandler(_IN_EVENT, |
286 _clientConnectionHandler != null ? _connectionHandler : null); | 286 _clientConnectionHandler != null ? _connectionHandler : null); |
287 } | 287 } |
288 | 288 |
289 void _connectionHandler() { | 289 void _connectionHandler() { |
290 if (_id >= 0) { | 290 if (_id >= 0) { |
291 _Socket socket = new _Socket._internal(); | 291 _Socket socket = new _Socket._internal(); |
292 var result = _accept(socket); | 292 var result = _accept(socket); |
293 if (result is OSError) { | 293 if (result is OSError) { |
294 _reportError(result, "Accept failed"); | 294 _reportError(result, "Accept failed"); |
| 295 } else if (result) { |
| 296 _clientConnectionHandler(socket); |
295 } else { | 297 } else { |
296 _clientConnectionHandler(socket); | 298 // Temporary failure accepting the connection. Ignoring |
| 299 // temporary failures lets us retry when we wake up with data |
| 300 // on the listening socket again. |
297 } | 301 } |
298 } | 302 } |
299 } | 303 } |
300 | 304 |
301 bool _isListenSocket() => true; | 305 bool _isListenSocket() => true; |
302 bool _isPipe() => false; | 306 bool _isPipe() => false; |
303 | 307 |
304 var _clientConnectionHandler; | 308 var _clientConnectionHandler; |
305 } | 309 } |
306 | 310 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 558 } |
555 | 559 |
556 bool _seenFirstOutEvent = false; | 560 bool _seenFirstOutEvent = false; |
557 bool _pipe = false; | 561 bool _pipe = false; |
558 Function _clientConnectHandler; | 562 Function _clientConnectHandler; |
559 Function _clientWriteHandler; | 563 Function _clientWriteHandler; |
560 SocketInputStream _inputStream; | 564 SocketInputStream _inputStream; |
561 SocketOutputStream _outputStream; | 565 SocketOutputStream _outputStream; |
562 static SendPort _socketService; | 566 static SendPort _socketService; |
563 } | 567 } |
OLD | NEW |