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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 361 } |
362 | 362 |
363 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET { | 363 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET { |
364 eventHandlers = new List(EVENT_COUNT + 1); | 364 eventHandlers = new List(EVENT_COUNT + 1); |
365 } | 365 } |
366 | 366 |
367 _NativeSocket.pipe() : typeFlags = TYPE_PIPE { | 367 _NativeSocket.pipe() : typeFlags = TYPE_PIPE { |
368 eventHandlers = new List(EVENT_COUNT + 1); | 368 eventHandlers = new List(EVENT_COUNT + 1); |
369 } | 369 } |
370 | 370 |
| 371 _NativeSocket.watch(int id) : typeFlags = TYPE_NORMAL_SOCKET { |
| 372 eventHandlers = new List(EVENT_COUNT + 1); |
| 373 isClosedWrite = true; |
| 374 nativeSetSocketId(id); |
| 375 } |
| 376 |
371 int available() { | 377 int available() { |
372 if (isClosing || isClosed) return 0; | 378 if (isClosing || isClosed) return 0; |
373 var result = nativeAvailable(); | 379 var result = nativeAvailable(); |
374 if (result is OSError) { | 380 if (result is OSError) { |
375 reportError(result, "Available failed"); | 381 reportError(result, "Available failed"); |
376 return 0; | 382 return 0; |
377 } else { | 383 } else { |
378 return result; | 384 return result; |
379 } | 385 } |
380 } | 386 } |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 // For all errors we close the socket | 652 // For all errors we close the socket |
647 close(); | 653 close(); |
648 } | 654 } |
649 | 655 |
650 bool setOption(SocketOption option, bool enabled) { | 656 bool setOption(SocketOption option, bool enabled) { |
651 if (option is! SocketOption) throw new ArgumentError(options); | 657 if (option is! SocketOption) throw new ArgumentError(options); |
652 if (enabled is! bool) throw new ArgumentError(enabled); | 658 if (enabled is! bool) throw new ArgumentError(enabled); |
653 return nativeSetOption(option._value, enabled); | 659 return nativeSetOption(option._value, enabled); |
654 } | 660 } |
655 | 661 |
| 662 void nativeSetSocketId(int id) native "Socket_SetSocketId"; |
656 nativeAvailable() native "Socket_Available"; | 663 nativeAvailable() native "Socket_Available"; |
657 nativeRead(int len) native "Socket_Read"; | 664 nativeRead(int len) native "Socket_Read"; |
658 nativeWrite(List<int> buffer, int offset, int bytes) | 665 nativeWrite(List<int> buffer, int offset, int bytes) |
659 native "Socket_WriteList"; | 666 native "Socket_WriteList"; |
660 nativeCreateConnect(List<int> addr, | 667 nativeCreateConnect(List<int> addr, |
661 int port) native "Socket_CreateConnect"; | 668 int port) native "Socket_CreateConnect"; |
662 nativeCreateBindListen(List<int> addr, int port, int backlog, bool v6Only) | 669 nativeCreateBindListen(List<int> addr, int port, int backlog, bool v6Only) |
663 native "ServerSocket_CreateBindListen"; | 670 native "ServerSocket_CreateBindListen"; |
664 nativeAccept(_NativeSocket socket) native "ServerSocket_Accept"; | 671 nativeAccept(_NativeSocket socket) native "ServerSocket_Accept"; |
665 int nativeGetPort() native "Socket_GetPort"; | 672 int nativeGetPort() native "Socket_GetPort"; |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 if (_detachReady != null) { | 1224 if (_detachReady != null) { |
1218 _detachReady.complete(null); | 1225 _detachReady.complete(null); |
1219 } else { | 1226 } else { |
1220 if (_raw != null) { | 1227 if (_raw != null) { |
1221 _raw.shutdown(SocketDirection.SEND); | 1228 _raw.shutdown(SocketDirection.SEND); |
1222 _disableWriteEvent(); | 1229 _disableWriteEvent(); |
1223 } | 1230 } |
1224 } | 1231 } |
1225 } | 1232 } |
1226 } | 1233 } |
OLD | NEW |