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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 _NativeSocket.watch(int id) : typeFlags = TYPE_NORMAL_SOCKET { | 442 _NativeSocket.watch(int id) : typeFlags = TYPE_NORMAL_SOCKET { |
443 isClosedWrite = true; | 443 isClosedWrite = true; |
444 nativeSetSocketId(id); | 444 nativeSetSocketId(id); |
445 } | 445 } |
446 | 446 |
447 List<int> read(int len) { | 447 List<int> read(int len) { |
448 if (len != null && len <= 0) { | 448 if (len != null && len <= 0) { |
449 throw new ArgumentError("Illegal length $len"); | 449 throw new ArgumentError("Illegal length $len"); |
450 } | 450 } |
451 if (isClosing || isClosed) return null; | 451 if (isClosing || isClosed) return null; |
452 var result = nativeRead(min(available, len == null ? available : len)); | 452 len = min(available, len == null ? available : len); |
| 453 if (len == 0) return null; |
| 454 var result = nativeRead(len); |
453 if (result is OSError) { | 455 if (result is OSError) { |
454 reportError(result, "Read failed"); | 456 reportError(result, "Read failed"); |
455 return null; | 457 return null; |
456 } | 458 } |
457 if (result != null) available -= result.length; | 459 if (result != null) available -= result.length; |
458 return result; | 460 return result; |
459 } | 461 } |
460 | 462 |
461 Datagram receive() { | 463 Datagram receive() { |
462 if (isClosing || isClosed) return null; | 464 if (isClosing || isClosed) return null; |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 | 1589 |
1588 Datagram _makeDatagram(List<int> data, | 1590 Datagram _makeDatagram(List<int> data, |
1589 String address, | 1591 String address, |
1590 List<int> in_addr, | 1592 List<int> in_addr, |
1591 int port) { | 1593 int port) { |
1592 return new Datagram( | 1594 return new Datagram( |
1593 data, | 1595 data, |
1594 new _InternetAddress(address, null, in_addr), | 1596 new _InternetAddress(address, null, in_addr), |
1595 port); | 1597 port); |
1596 } | 1598 } |
OLD | NEW |