Issue #15560 has been updated by ioquatix (Samuel Williams).


It is useful for read when user wants to read some data, and it wasn't enough (e.g. implementing `gets`) so you need to read some more at the end of what you already have.

----------------------------------------
Feature #15560: Add support for read/write offsets.
https://bugs.ruby-lang.org/issues/15560#change-76521

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 2.7
----------------------------------------
It would be nice if read/write/send/recv/etc methods could accept an offset argument.

e.g.

```
socket = Socket.new(...)
buffer = String.b

socket.read(1024, buffer)
socket.read(1024, buffer, offset: buffer.bytesize)
```

The same for write, e.g.

```
socket = Socket.new(...)
buffer = String.b

amount = socket.write(buffer)
socket.write(buffer, offset: amount)
```

Could also include "size:" so that we can selectively write parts of the buffer.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>