ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:91235] [Ruby trunk Feature#15560] Add support for read/write offsets.
       [not found] <redmine.issue-15560.20190123213952@ruby-lang.org>
@ 2019-01-23 21:39 ` samuel
  2019-01-26 20:52   ` [ruby-core:91290] " Eric Wong
  2019-01-24  1:29 ` [ruby-core:91239] " shyouhei
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 5+ messages in thread
From: samuel @ 2019-01-23 21:39 UTC (permalink / raw)
  To: ruby-core

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

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:91239] [Ruby trunk Feature#15560] Add support for read/write offsets.
       [not found] <redmine.issue-15560.20190123213952@ruby-lang.org>
  2019-01-23 21:39 ` [ruby-core:91235] [Ruby trunk Feature#15560] Add support for read/write offsets samuel
@ 2019-01-24  1:29 ` shyouhei
  2019-01-26  8:30 ` [ruby-core:91274] " samuel
  2019-01-26 11:01 ` [ruby-core:91279] " samuel
  3 siblings, 0 replies; 5+ messages in thread
From: shyouhei @ 2019-01-24  1:29 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:91274] [Ruby trunk Feature#15560] Add support for read/write offsets.
       [not found] <redmine.issue-15560.20190123213952@ruby-lang.org>
  2019-01-23 21:39 ` [ruby-core:91235] [Ruby trunk Feature#15560] Add support for read/write offsets samuel
  2019-01-24  1:29 ` [ruby-core:91239] " shyouhei
@ 2019-01-26  8:30 ` samuel
  2019-01-26 11:01 ` [ruby-core:91279] " samuel
  3 siblings, 0 replies; 5+ messages in thread
From: samuel @ 2019-01-26  8:30 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:91279] [Ruby trunk Feature#15560] Add support for read/write offsets.
       [not found] <redmine.issue-15560.20190123213952@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-01-26  8:30 ` [ruby-core:91274] " samuel
@ 2019-01-26 11:01 ` samuel
  3 siblings, 0 replies; 5+ messages in thread
From: samuel @ 2019-01-26 11:01 UTC (permalink / raw)
  To: ruby-core

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


Also, rather than using a keyword argument, it could be a 3rd argument after buffer, since buffer must be supplied in order for this to work.

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:91290] Re: [Ruby trunk Feature#15560] Add support for read/write offsets.
  2019-01-23 21:39 ` [ruby-core:91235] [Ruby trunk Feature#15560] Add support for read/write offsets samuel
@ 2019-01-26 20:52   ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2019-01-26 20:52 UTC (permalink / raw)
  To: ruby-core

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

Fwiw, Perl5 has had these features since forever and they're
immensely useful for non-blocking I/O.

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

Yes, perl's syswrite and IO::Handle->write has this, too.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-26 20:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-15560.20190123213952@ruby-lang.org>
2019-01-23 21:39 ` [ruby-core:91235] [Ruby trunk Feature#15560] Add support for read/write offsets samuel
2019-01-26 20:52   ` [ruby-core:91290] " Eric Wong
2019-01-24  1:29 ` [ruby-core:91239] " shyouhei
2019-01-26  8:30 ` [ruby-core:91274] " samuel
2019-01-26 11:01 ` [ruby-core:91279] " samuel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).