| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 561 } |
| 562 | 562 |
| 563 Datagram receive() { | 563 Datagram receive() { |
| 564 if (isClosing || isClosed) return null; | 564 if (isClosing || isClosed) return null; |
| 565 var result = nativeRecvFrom(); | 565 var result = nativeRecvFrom(); |
| 566 if (result is OSError) { | 566 if (result is OSError) { |
| 567 reportError(result, "Receive failed"); | 567 reportError(result, "Receive failed"); |
| 568 return null; | 568 return null; |
| 569 } | 569 } |
| 570 if (result != null) { | 570 if (result != null) { |
| 571 if (Platform.isMacOS) { | 571 // Read the next available. Available is only for the next datagram, not |
| 572 // Mac includes the header size, so we need to query the actual | 572 // the sum of all datagrams pending, so we need to call after each |
| 573 // available. | 573 // receive. If available becomes > 0, the _NativeSocket will continue to |
| 574 available = nativeAvailable(); | 574 // emit read events. |
| 575 } else { | 575 available = nativeAvailable(); |
| 576 available -= result.data.length; | |
| 577 } | |
| 578 totalRead += result.data.length; | 576 totalRead += result.data.length; |
| 579 } | 577 } |
| 580 readCount++; | 578 readCount++; |
| 581 lastRead = timestamp; | 579 lastRead = timestamp; |
| 582 return result; | 580 return result; |
| 583 } | 581 } |
| 584 | 582 |
| 585 int write(List<int> buffer, int offset, int bytes) { | 583 int write(List<int> buffer, int offset, int bytes) { |
| 586 if (buffer is! List) throw new ArgumentError(); | 584 if (buffer is! List) throw new ArgumentError(); |
| 587 if (offset == null) offset = 0; | 585 if (offset == null) offset = 0; |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 String address, | 1927 String address, |
| 1930 List<int> in_addr, | 1928 List<int> in_addr, |
| 1931 int port) { | 1929 int port) { |
| 1932 return new Datagram( | 1930 return new Datagram( |
| 1933 data, | 1931 data, |
| 1934 new _InternetAddress(address, null, in_addr), | 1932 new _InternetAddress(address, null, in_addr), |
| 1935 port); | 1933 port); |
| 1936 } | 1934 } |
| 1937 | 1935 |
| 1938 String _socketsStats() => _SocketsObservatory.toJSON(); | 1936 String _socketsStats() => _SocketsObservatory.toJSON(); |
| OLD | NEW |