Chromium Code Reviews| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // Read the next available. Available is only for the next datagram, not | 571 // Read the next available. Available is only for the next datagram, not |
| 572 // the sum of all datagrams pending, so we need to call after each | 572 // the sum of all datagrams pending, so we need to call after each |
| 573 // receive. If available becomes > 0, the _NativeSocket will continue to | 573 // receive. If available becomes > 0, the _NativeSocket will continue to |
| 574 // emit read events. | 574 // emit read events. |
| 575 available = nativeAvailable(); | 575 var avail = nativeAvailable(); |
| 576 if (avail != null) { | |
| 577 available = avail; | |
| 578 } | |
|
Ivan Posva
2014/10/09 06:12:07
available = (avail != null) avail : 1;
With the s
Anders Johnsen
2014/10/09 06:17:07
Done.
| |
| 576 totalRead += result.data.length; | 579 totalRead += result.data.length; |
| 577 } | 580 } |
| 578 readCount++; | 581 readCount++; |
| 579 lastRead = timestamp; | 582 lastRead = timestamp; |
| 580 return result; | 583 return result; |
| 581 } | 584 } |
| 582 | 585 |
| 583 int write(List<int> buffer, int offset, int bytes) { | 586 int write(List<int> buffer, int offset, int bytes) { |
| 584 if (buffer is! List) throw new ArgumentError(); | 587 if (buffer is! List) throw new ArgumentError(); |
| 585 if (offset == null) offset = 0; | 588 if (offset == null) offset = 0; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 writeAvailable = true; | 741 writeAvailable = true; |
| 739 issueWriteEvent(delayed: false); | 742 issueWriteEvent(delayed: false); |
| 740 continue; | 743 continue; |
| 741 } | 744 } |
| 742 | 745 |
| 743 if (i == READ_EVENT) { | 746 if (i == READ_EVENT) { |
| 744 if (isListening) { | 747 if (isListening) { |
| 745 available++; | 748 available++; |
| 746 } else { | 749 } else { |
| 747 var avail = nativeAvailable(); | 750 var avail = nativeAvailable(); |
| 748 if (avail is int) { | 751 if (avail != null) { |
| 749 available = avail; | 752 available = avail; |
| 750 } else { | 753 } else { |
| 751 // Available failed. Mark socket as having data, to ensure read | 754 // Available failed. Mark socket as having data, to ensure read |
| 752 // events, and thus reporting of this error. | 755 // events, and thus reporting of this error. |
| 753 available = 1; | 756 available = 1; |
|
Ivan Posva
2014/10/09 06:12:07
ditto.
Anders Johnsen
2014/10/09 06:17:07
Done.
| |
| 754 } | 757 } |
| 755 issueReadEvent(); | 758 issueReadEvent(); |
| 756 continue; | 759 continue; |
| 757 } | 760 } |
| 758 } | 761 } |
| 759 | 762 |
| 760 var handler = eventHandlers[i]; | 763 var handler = eventHandlers[i]; |
| 761 if (i == DESTROYED_EVENT) { | 764 if (i == DESTROYED_EVENT) { |
| 762 assert(isClosing); | 765 assert(isClosing); |
| 763 assert(!isClosed); | 766 assert(!isClosed); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1927 String address, | 1930 String address, |
| 1928 List<int> in_addr, | 1931 List<int> in_addr, |
| 1929 int port) { | 1932 int port) { |
| 1930 return new Datagram( | 1933 return new Datagram( |
| 1931 data, | 1934 data, |
| 1932 new _InternetAddress(address, null, in_addr), | 1935 new _InternetAddress(address, null, in_addr), |
| 1933 port); | 1936 port); |
| 1934 } | 1937 } |
| 1935 | 1938 |
| 1936 String _socketsStats() => _SocketsObservatory.toJSON(); | 1939 String _socketsStats() => _SocketsObservatory.toJSON(); |
| OLD | NEW |