October 10, 2016
On Monday, 26 September 2016 at 23:40:10 UTC, Vincent wrote:
> Hello, guys!
>
> I was very surprised that module 'socketstream' was deprecated. Usually if something become obsolete, there is some perfect replacement! But my digging in Inet and forums gave nothing, but "outdated" examples with 'SocketStream' class. So first question is WHAT Phobos has to replace SocketStream?

Hello, I'm agree with your main question.

This looks very good http://dsfml.com/docs/sockets.html, but, there is no any answer for the question. Why 'socketstream' was deprecated when no any replacement modules? It looks strange, like you are removing feature from your app because his code old and don't write new code for same feature, and just say to users: no feature anymore, haha.

So anyone know the answer?

October 09, 2016
On Monday, October 10, 2016 01:43:54 Konstantin Kutsevalov via Digitalmars-d- learn wrote:
> Why 'socketstream' was
> deprecated when no any replacement modules? It looks strange,
> like you are removing feature from your app because his code old
> and don't write new code for same feature, and just say to users:
> no feature anymore, haha.
>
> So anyone know the answer?

Quite some time ago, it was decided that the *stream modules as they were were unacceptable and that they needed to be replaced with something range-based (they come from early D1 and have never really been updated since), and they were marked in their documentation to indicate that they were going to be removed in the future. But apparently, no one cared enough about that functionality to actually design a replacement, and it sat there for years. So, it was finally decided that rather than just having code that was not up to our current standards sit there with a warning on it, it should be removed. So, they those modules were deprecated (and will be fully removed in the next release).

I'm sure that part of what it comes down to is that ranges in generally largely slove the problem that a stream tries to solve (though std.socket unfortunately doesn't provide an easy way to get a range over a socket), making the *stream modules largely redundant, and the read, write, and peek functions in std.bitmanip do a lot of the rest of what would need to be done with a stream that isn't natively part of a range. So, enough of the functionality is there in a more general form that a replacement isn't necessarily needed (even if it might be nice), and if anyone cared enough to do it, they haven't tried to get it into Phobos (or even put it up on code.dlang.org AFAIK).

Clearly, some folks use the *stream stuff, but it doesn't seem like many do, and it's also clear that - for whatever reason - no one has cared enough to come up with a replacement for Phobos. So, it's simply gone. But if someone wants to propose a replacement, they're certainly still free to do so.

- Jonathan M Davis

October 10, 2016
Dne 10.10.2016 v 03:43 Konstantin Kutsevalov via Digitalmars-d-learn napsal(a):

> On Monday, 26 September 2016 at 23:40:10 UTC, Vincent wrote:
>> Hello, guys!
>>
>> I was very surprised that module 'socketstream' was deprecated. Usually if something become obsolete, there is some perfect replacement! But my digging in Inet and forums gave nothing, but "outdated" examples with 'SocketStream' class. So first question is WHAT Phobos has to replace SocketStream?
>
> Hello, I'm agree with your main question.
>
> This looks very good http://dsfml.com/docs/sockets.html, but, there is no any answer for the question. Why 'socketstream' was deprecated when no any replacement modules? It looks strange, like you are removing feature from your app because his code old and don't write new code for same feature, and just say to users: no feature anymore, haha.
>
> So anyone know the answer?
>

Until some replacment will occure in phobos socketstream is and will be available through https://code.dlang.org/packages/undead
October 10, 2016
Wrote some pretty simple sockets that you could use (Based on vibe.d though.)

https://github.com/bausshf/cheetah
October 10, 2016
On Monday, 10 October 2016 at 02:54:09 UTC, Jonathan M Davis wrote:
> On Monday, October 10, 2016 01:43:54 Konstantin Kutsevalov via So, it's simply gone. But if someone wants to propose a replacement, they're certainly still free to do so.
>
> - Jonathan M Davis

I see, thank you for answer
October 10, 2016
On Monday, 10 October 2016 at 07:37:48 UTC, Bauss wrote:
> Wrote some pretty simple sockets that you could use (Based on vibe.d though.)
>
> https://github.com/bausshf/cheetah

Hi,

Yes I saw it, but not sure. Does it make sense to use vibe.d only for sockets. I mean, it like a web framework with many dependencies etc...
December 03, 2022
On Saturday, 8 October 2016 at 17:52:25 UTC, Karabuta wrote:
> This is how a usable socket in a standard library should be http://dsfml.com/docs/sockets.html. This is using DSFML (a D bindings to SFML).

Pity, doesn't exist anymore.
December 03, 2022
On Monday, 10 October 2016 at 07:37:48 UTC, Bauss wrote:
> Wrote some pretty simple sockets that you could use (Based on vibe.d though.)

That's the point! STANDARD library cannot/must not rely on bloatware like vibe.d; Only small, native, non-depended socket implementation.
December 03, 2022
On Monday, 10 October 2016 at 02:54:09 UTC, Jonathan M Davis wrote:

> Quite some time ago, it was decided that the *stream modules as they were were unacceptable and that they needed to be replaced with something range-based

That's the key! Absolutely dilettantish solution of "profi", biased on ranges.
Unfortunately even TECHNICALLY stream never was a "range"! It's more like "queue of bytes", where you can never be sure you even get these bytes.

Moreover - "socket stream" is such a specific stream that you cannot assume even bytes data! Many protocols rely on STRINGS, so SocketStream have to have dual nature - byte-based and string-based. Even worse - if you read stupid HTTP standard, it allows for server to reply with strings (header), followed by RAW BYTES(!). Surprise! So in this light we cannot speak about ranges AT ALL. We need stream, which supports strings and at the same time bytes. And all of that in convenient way, not just "auto b = GimmeStupidHeapOfBytesWhichAreString".

Anyway, it's quite unprofessional to remove SocketStream: it DOES NOT fit at all in "range" ideology (as well as, say, Window or Button) and lives own life. "Ranges" just PART of library, not a whole library! In other words not everything in a library should follow "ranges ideology".

I ask to return standard SocketStream and keep it until that "smartie" (who remove it) will write fully functional replacement.

Nobody will use D if maintainers will stupidly throw away classes by own wish. Keep functionality as big as possible, because D even now, after "stable language", still lie on road edge.
December 06, 2022

On Saturday, 3 December 2022 at 11:08:53 UTC, Vincent wrote:

>

Unfortunately even TECHNICALLY stream never was a "range"! It's more like "queue of bytes", where you can never be sure you even get these bytes.

A stream is exactly a range, a "range of ranges" if more specifically. All network devices work with chunks of data (buffers), either it's 1 byte or 4096 bytes in size.

So, such ranges may work either with strings (with "\n" terminator, like byLine or your readLine example), or a chunk of bytes (like byChunk).


As for your request about "Easy sockets": it seems there is nothing like that available for now in the standard library. Besides, your example with google is oversimplified: for example, there is no simple way to determine the transport layer protocol for a specific domain name and port:

auto sock = new ClientSocket("google.com", 80);
sock.WriteLine("GET / HTTP/1.0");

You can technically guess between IPv4 and IPv6 by resolving the address via DNS, but you can't guess TCP vs UDP without trying to connect to a host. Moreover, there are other protocols like QUIC, which is built on top of UDP but has different semantics.

However, your demand is quite understandable. There is some ongoing work toward these ideas.

For example, what would you say about the following interface:

auto s = socket("tcp://google.com:80");
s.connect();
s.writeln("Hello world");
s.close();

or, if asynchronous:

auto t1 = socket("tcp://google.com:80")
  .connect()
  .writeln("GET / HTTP/1.0")
  .readln((sock, msg) => doSomething());

auto t2 = socket("tcp://duckduckgo.com:80")
  .connect()
  .writeln("GET / HTTP/1.0")
  .readln((sock, msg) => doSomethingElse());

wait(t1, t2);
1 2
Next ›   Last »