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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 433 |
434 int get port { | 434 int get port { |
435 if (localPort != null) return localPort; | 435 if (localPort != null) return localPort; |
436 return localPort = nativeGetPort(); | 436 return localPort = nativeGetPort(); |
437 } | 437 } |
438 | 438 |
439 int get remotePort { | 439 int get remotePort { |
440 return nativeGetRemotePeer()[1]; | 440 return nativeGetRemotePeer()[1]; |
441 } | 441 } |
442 | 442 |
443 String get remoteHost { | 443 InternetAddress get remoteAddress { |
444 return nativeGetRemotePeer()[0]; | 444 var result = nativeGetRemotePeer()[0]; |
| 445 var type = new InternetAddressType._from(result[0]); |
| 446 return new _InternetAddress(type, result[1], "", result[2]); |
445 } | 447 } |
446 | 448 |
447 // Multiplexes socket events to the socket handlers. | 449 // Multiplexes socket events to the socket handlers. |
448 void multiplex(int events) { | 450 void multiplex(int events) { |
449 canActivateEvents = false; | 451 canActivateEvents = false; |
450 for (int i = FIRST_EVENT; i <= LAST_EVENT; i++) { | 452 for (int i = FIRST_EVENT; i <= LAST_EVENT; i++) { |
451 if (((events & (1 << i)) != 0)) { | 453 if (((events & (1 << i)) != 0)) { |
452 if (i == CLOSED_EVENT && | 454 if (i == CLOSED_EVENT && |
453 typeFlags != TYPE_LISTENING_SOCKET && | 455 typeFlags != TYPE_LISTENING_SOCKET && |
454 !isClosing && | 456 !isClosing && |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 Future close() => _socket.close().then((_) => this); | 836 Future close() => _socket.close().then((_) => this); |
835 | 837 |
836 void shutdown(SocketDirection direction) => _socket.shutdown(direction); | 838 void shutdown(SocketDirection direction) => _socket.shutdown(direction); |
837 | 839 |
838 int get port => _socket.port; | 840 int get port => _socket.port; |
839 | 841 |
840 int get remotePort => _socket.remotePort; | 842 int get remotePort => _socket.remotePort; |
841 | 843 |
842 InternetAddress get address => _socket.address; | 844 InternetAddress get address => _socket.address; |
843 | 845 |
844 String get remoteHost => _socket.remoteHost; | 846 InternetAddress get remoteAddress => _socket.remoteAddress; |
845 | 847 |
846 bool get readEventsEnabled => _readEventsEnabled; | 848 bool get readEventsEnabled => _readEventsEnabled; |
847 void set readEventsEnabled(bool value) { | 849 void set readEventsEnabled(bool value) { |
848 if (value != _readEventsEnabled) { | 850 if (value != _readEventsEnabled) { |
849 _readEventsEnabled = value; | 851 _readEventsEnabled = value; |
850 if (!_controller.isPaused) _resume(); | 852 if (!_controller.isPaused) _resume(); |
851 } | 853 } |
852 } | 854 } |
853 | 855 |
854 bool get writeEventsEnabled => _writeEventsEnabled; | 856 bool get writeEventsEnabled => _writeEventsEnabled; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 _controllerClosed = true; | 1107 _controllerClosed = true; |
1106 _controller.close(); | 1108 _controller.close(); |
1107 } | 1109 } |
1108 | 1110 |
1109 bool setOption(SocketOption option, bool enabled) { | 1111 bool setOption(SocketOption option, bool enabled) { |
1110 if (_raw == null) return false; | 1112 if (_raw == null) return false; |
1111 return _raw.setOption(option, enabled); | 1113 return _raw.setOption(option, enabled); |
1112 } | 1114 } |
1113 | 1115 |
1114 int get port => _raw.port; | 1116 int get port => _raw.port; |
1115 String get remoteHost => _raw.remoteHost; | 1117 InternetAddress get remoteAddress => _raw.remoteAddress; |
1116 int get remotePort => _raw.remotePort; | 1118 int get remotePort => _raw.remotePort; |
1117 | 1119 |
1118 Future _detachRaw() { | 1120 Future _detachRaw() { |
1119 _detachReady = new Completer(); | 1121 _detachReady = new Completer(); |
1120 _sink.close(); | 1122 _sink.close(); |
1121 return _detachReady.future.then((_) { | 1123 return _detachReady.future.then((_) { |
1122 assert(_consumer.buffer == null); | 1124 assert(_consumer.buffer == null); |
1123 var raw = _raw; | 1125 var raw = _raw; |
1124 _raw = null; | 1126 _raw = null; |
1125 return [raw, _subscription]; | 1127 return [raw, _subscription]; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 if (_detachReady != null) { | 1218 if (_detachReady != null) { |
1217 _detachReady.complete(null); | 1219 _detachReady.complete(null); |
1218 } else { | 1220 } else { |
1219 if (_raw != null) { | 1221 if (_raw != null) { |
1220 _raw.shutdown(SocketDirection.SEND); | 1222 _raw.shutdown(SocketDirection.SEND); |
1221 _disableWriteEvent(); | 1223 _disableWriteEvent(); |
1222 } | 1224 } |
1223 } | 1225 } |
1224 } | 1226 } |
1225 } | 1227 } |
OLD | NEW |