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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 if (result is OSError) { | 386 if (result is OSError) { |
387 reportError(result, "Read failed"); | 387 reportError(result, "Read failed"); |
388 return null; | 388 return null; |
389 } | 389 } |
390 return result; | 390 return result; |
391 } | 391 } |
392 | 392 |
393 int write(List<int> buffer, int offset, int bytes) { | 393 int write(List<int> buffer, int offset, int bytes) { |
394 if (buffer is! List) throw new ArgumentError(); | 394 if (buffer is! List) throw new ArgumentError(); |
395 if (offset == null) offset = 0; | 395 if (offset == null) offset = 0; |
396 if (bytes == null) bytes = buffer.length; | 396 if (bytes == null) { |
| 397 if (offset > buffer.length) { |
| 398 throw new RangeError.value(offset); |
| 399 } |
| 400 bytes = buffer.length - offset; |
| 401 } |
397 if (offset < 0) throw new RangeError.value(offset); | 402 if (offset < 0) throw new RangeError.value(offset); |
398 if (bytes < 0) throw new RangeError.value(bytes); | 403 if (bytes < 0) throw new RangeError.value(bytes); |
399 if ((offset + bytes) > buffer.length) { | 404 if ((offset + bytes) > buffer.length) { |
400 throw new RangeError.value(offset + bytes); | 405 throw new RangeError.value(offset + bytes); |
401 } | 406 } |
402 if (offset is! int || bytes is! int) { | 407 if (offset is! int || bytes is! int) { |
403 throw new ArgumentError("Invalid arguments to write on Socket"); | 408 throw new ArgumentError("Invalid arguments to write on Socket"); |
404 } | 409 } |
405 if (isClosed) return 0; | 410 if (isClosed) return 0; |
406 if (bytes == 0) return 0; | 411 if (bytes == 0) return 0; |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 if (_detachReady != null) { | 1197 if (_detachReady != null) { |
1193 _detachReady.complete(null); | 1198 _detachReady.complete(null); |
1194 } else { | 1199 } else { |
1195 if (_raw != null) { | 1200 if (_raw != null) { |
1196 _raw.shutdown(SocketDirection.SEND); | 1201 _raw.shutdown(SocketDirection.SEND); |
1197 _disableWriteEvent(); | 1202 _disableWriteEvent(); |
1198 } | 1203 } |
1199 } | 1204 } |
1200 } | 1205 } |
1201 } | 1206 } |
OLD | NEW |