From: shyouhei@... Date: 2019-01-24T01:29:29+00:00 Subject: [ruby-core:91239] [Ruby trunk Feature#15560] Add support for read/write offsets. Issue #15560 has been updated by shyouhei (Shyouhei Urabe). I can imagine it is useful for TCPSocket#write to accept only a part of a buffer crafted by somebody else. But I cannot think of any actual use case when #read is useful with that extension. Do you have one? ---------------------------------------- Feature #15560: Add support for read/write offsets. https://bugs.ruby-lang.org/issues/15560#change-76484 * 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: