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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 _controller.add(RawSocketEvent.CLOSED); | 957 _controller.add(RawSocketEvent.CLOSED); |
958 _controller.close(); | 958 _controller.close(); |
959 }, | 959 }, |
960 error: zone.bindUnaryCallback((e) { | 960 error: zone.bindUnaryCallback((e) { |
961 _controller.addError(e); | 961 _controller.addError(e); |
962 _socket.close(); | 962 _socket.close(); |
963 }) | 963 }) |
964 ); | 964 ); |
965 } | 965 } |
966 | 966 |
967 factory _RawSocket._writePipe(int fd) { | 967 factory _RawSocket._writePipe() { |
968 var native = new _NativeSocket.pipe(); | 968 var native = new _NativeSocket.pipe(); |
969 native.isClosedRead = true; | 969 native.isClosedRead = true; |
970 if (fd != null) _getStdioHandle(native, fd); | |
971 return new _RawSocket(native); | 970 return new _RawSocket(native); |
972 } | 971 } |
973 | 972 |
974 factory _RawSocket._readPipe(int fd) { | 973 factory _RawSocket._readPipe(int fd) { |
975 var native = new _NativeSocket.pipe(); | 974 var native = new _NativeSocket.pipe(); |
976 native.isClosedWrite = true; | 975 native.isClosedWrite = true; |
977 if (fd != null) _getStdioHandle(native, fd); | 976 if (fd != null) _getStdioHandle(native, fd); |
978 var result = new _RawSocket(native); | 977 var result = new _RawSocket(native); |
979 result._isMacOSTerminalInput = | 978 result._isMacOSTerminalInput = |
980 Platform.isMacOS && | 979 Platform.isMacOS && |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 _consumer = new _SocketStreamConsumer(this); | 1225 _consumer = new _SocketStreamConsumer(this); |
1227 _sink = new IOSink(_consumer); | 1226 _sink = new IOSink(_consumer); |
1228 | 1227 |
1229 // Disable read events until there is a subscription. | 1228 // Disable read events until there is a subscription. |
1230 _raw.readEventsEnabled = false; | 1229 _raw.readEventsEnabled = false; |
1231 | 1230 |
1232 // Disable write events until the consumer needs it for pending writes. | 1231 // Disable write events until the consumer needs it for pending writes. |
1233 _raw.writeEventsEnabled = false; | 1232 _raw.writeEventsEnabled = false; |
1234 } | 1233 } |
1235 | 1234 |
1236 factory _Socket._writePipe([int fd]) { | 1235 factory _Socket._writePipe() { |
1237 return new _Socket(new _RawSocket._writePipe(fd)); | 1236 return new _Socket(new _RawSocket._writePipe()); |
1238 } | 1237 } |
1239 | 1238 |
1240 factory _Socket._readPipe([int fd]) { | 1239 factory _Socket._readPipe([int fd]) { |
1241 return new _Socket(new _RawSocket._readPipe(fd)); | 1240 return new _Socket(new _RawSocket._readPipe(fd)); |
1242 } | 1241 } |
1243 | 1242 |
1244 _NativeSocket get _nativeSocket => _raw._socket; | 1243 _NativeSocket get _nativeSocket => _raw._socket; |
1245 | 1244 |
1246 StreamSubscription<List<int>> listen(void onData(List<int> event), | 1245 StreamSubscription<List<int>> listen(void onData(List<int> event), |
1247 {Function onError, | 1246 {Function onError, |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1550 |
1552 Datagram _makeDatagram(List<int> data, | 1551 Datagram _makeDatagram(List<int> data, |
1553 String address, | 1552 String address, |
1554 List<int> in_addr, | 1553 List<int> in_addr, |
1555 int port) { | 1554 int port) { |
1556 return new Datagram( | 1555 return new Datagram( |
1557 data, | 1556 data, |
1558 new _InternetAddress(address, null, in_addr), | 1557 new _InternetAddress(address, null, in_addr), |
1559 port); | 1558 port); |
1560 } | 1559 } |
OLD | NEW |