Thread overview
What's going to replace std.stream?
Feb 06, 2016
cy
Feb 06, 2016
Jakob Ovrum
Feb 06, 2016
cy
Feb 16, 2016
landaire
February 06, 2016
Let's say I have a socket, and a file, and I want to send the contents of that file to the socket. What's the best way to do that? Yes I'm aware that in Linux, you can use a combination of a pipe and splice(2) to keep all buffers kernel side for that, but I was thinking more generally. The traditional C way is to read() into a buffer, then write() it out, until the input is exhausted. But apparantly in D we're not supposed to do that?

It's just that I tried to use std.stream, and found that the whole module had been marked as deprecated some time last year. What exactly is going to replace it? Some sort of lazy file contents accessor, that can take advantage of zero copy things like splice() when hooked together? A source/sink paradigm maybe?

I don't see anything analagous to what std.stream does in phobos... has it just not been made public yet?
February 06, 2016
On Saturday, 6 February 2016 at 06:29:56 UTC, cy wrote:
> Let's say I have a socket, and a file, and I want to send the contents of that file to the socket. What's the best way to do that? Yes I'm aware that in Linux, you can use a combination of a pipe and splice(2) to keep all buffers kernel side for that, but I was thinking more generally. The traditional C way is to read() into a buffer, then write() it out, until the input is exhausted. But apparantly in D we're not supposed to do that?
>
> It's just that I tried to use std.stream, and found that the whole module had been marked as deprecated some time last year. What exactly is going to replace it? Some sort of lazy file contents accessor, that can take advantage of zero copy things like splice() when hooked together? A source/sink paradigm maybe?
>
> I don't see anything analagous to what std.stream does in phobos... has it just not been made public yet?

There are some third party libraries that implement streams [1], but your example can be done like:

foreach(chunk; File("path/to/file").byChunk(16 * 1024))
    socket.write(chunk);

[1] e.g. http://code.dlang.org/packages/io
February 06, 2016
On Saturday, 6 February 2016 at 08:24:59 UTC, Jakob Ovrum wrote:
> foreach(chunk; File("path/to/file").byChunk(16 * 1024))

Ohh, cool so the streaming...ish logic is in std.stdio now. I thought that module was only for text output.
February 16, 2016
On Saturday, 6 February 2016 at 06:29:56 UTC, cy wrote:
> I don't see anything analagous to what std.stream does in phobos... has it just not been made public yet?

This was actually something that kind of killed my vibe when I was working on a project recently. I wanted to use some interface that allowed reading/writing that I could wrap to specify endianness and some other attributes but couldn't find any good replacement.