| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class SocketInputStream implements InputStream { | 5 class SocketInputStream implements InputStream { |
| 6 SocketInputStream(Socket socket) { | 6 SocketInputStream(Socket socket) { |
| 7 _socket = socket; | 7 _socket = socket; |
| 8 } | 8 } |
| 9 | 9 |
| 10 List<int> read([int len]) { | 10 List<int> read([int len]) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 if (bytesRead < bytesToRead) { | 22 if (bytesRead < bytesToRead) { |
| 23 List<int> newBuffer = new List<int>(bytesRead); | 23 List<int> newBuffer = new List<int>(bytesRead); |
| 24 newBuffer.copyFrom(buffer, 0, 0, bytesRead); | 24 newBuffer.copyFrom(buffer, 0, 0, bytesRead); |
| 25 return newBuffer; | 25 return newBuffer; |
| 26 } else { | 26 } else { |
| 27 return buffer; | 27 return buffer; |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 int readInto(List<int> buffer, int offset, int len) { | 31 int readInto(List<int> buffer, int offset, int len) { |
| 32 if (offset == null) offset = 0; | 32 if (offset === null) offset = 0; |
| 33 if (len == null) len = buffer.length; | 33 if (len === null) len = buffer.length; |
| 34 if (offset < 0) throw new StreamException("Illegal offset $offset"); | 34 if (offset < 0) throw new StreamException("Illegal offset $offset"); |
| 35 if (len < 0) throw new StreamException("Illegal length $len"); | 35 if (len < 0) throw new StreamException("Illegal length $len"); |
| 36 return _socket.readList(buffer, offset, len); | 36 return _socket.readList(buffer, offset, len); |
| 37 } | 37 } |
| 38 | 38 |
| 39 int available() { | 39 int available() { |
| 40 return _socket.available(); | 40 return _socket.available(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void set dataHandler(void callback()) { | 43 void set dataHandler(void callback()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 if (bytesWritten == len) { | 78 if (bytesWritten == len) { |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 _socket.setWriteHandler(finishWrite); | 81 _socket.setWriteHandler(finishWrite); |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 Socket _socket; | 85 Socket _socket; |
| 86 } | 86 } |
| OLD | NEW |