digitalmars.D.learn - std.socket replacement
- tired_eyes (7/7) Nov 29 2015 I was a bit surprised to see that std.socket is deprecated as of
- tcak (4/11) Nov 29 2015 I would say "WTF" at first, then checked the documentation, but
- tired_eyes (3/15) Nov 29 2015 Wow, sorry, I meant std.stream and std.socketstream, not
- Alex Parrill (3/19) Nov 29 2015 std.stream, and the stream interface in general, is deprecated in
- tired_eyes (22/24) Nov 29 2015 Could you please give a small example?
- Max Freck (22/46) Sep 03 2016 In case someone is still looking for the answer, just like me. It
I was a bit surprised to see that std.socket is deprecated as of 2.069. Just curious, what's wrong with it? And what should I use as a replacement? I know there is vibe.socket, but I don't want to include fullstack web framework as a dependency just to make some HTTP reqests. I also don't see any proposed replacements in a review queue. Will std.socket and std.socketstream be just thrown away?
Nov 29 2015
On Sunday, 29 November 2015 at 08:56:30 UTC, tired_eyes wrote:I was a bit surprised to see that std.socket is deprecated as of 2.069. Just curious, what's wrong with it? And what should I use as a replacement? I know there is vibe.socket, but I don't want to include fullstack web framework as a dependency just to make some HTTP reqests. I also don't see any proposed replacements in a review queue. Will std.socket and std.socketstream be just thrown away?I would say "WTF" at first, then checked the documentation, but don't see anything about deprecation. My current whole business relies on that.
Nov 29 2015
On Sunday, 29 November 2015 at 09:05:37 UTC, tcak wrote:On Sunday, 29 November 2015 at 08:56:30 UTC, tired_eyes wrote:Wow, sorry, I meant std.stream and std.socketstream, not std.socket and std.socketstreamI was a bit surprised to see that std.socket is deprecated as of 2.069. Just curious, what's wrong with it? And what should I use as a replacement? I know there is vibe.socket, but I don't want to include fullstack web framework as a dependency just to make some HTTP reqests. I also don't see any proposed replacements in a review queue. Will std.socket and std.socketstream be just thrown away?I would say "WTF" at first, then checked the documentation, but don't see anything about deprecation. My current whole business relies on that.
Nov 29 2015
On Sunday, 29 November 2015 at 09:12:14 UTC, tired_eyes wrote:On Sunday, 29 November 2015 at 09:05:37 UTC, tcak wrote:std.stream, and the stream interface in general, is deprecated in favor of ranges, which are more generic and flexible.On Sunday, 29 November 2015 at 08:56:30 UTC, tired_eyes wrote:Wow, sorry, I meant std.stream and std.socketstream, not std.socket and std.socketstreamI was a bit surprised to see that std.socket is deprecated as of 2.069. Just curious, what's wrong with it? And what should I use as a replacement? I know there is vibe.socket, but I don't want to include fullstack web framework as a dependency just to make some HTTP reqests. I also don't see any proposed replacements in a review queue. Will std.socket and std.socketstream be just thrown away?I would say "WTF" at first, then checked the documentation, but don't see anything about deprecation. My current whole business relies on that.
Nov 29 2015
On Sunday, 29 November 2015 at 16:10:22 UTC, Alex Parrill wrote:std.stream, and the stream interface in general, is deprecated in favor of ranges, which are more generic and flexible.Could you please give a small example? Consider this minimal app: import std.stdio; import std.socket; import std.socketstream; void main() { auto socket = new TcpSocket(new InternetAddress("dlang.org", 80)); scope(exit) socket.close(); auto ss = new SocketStream(socket); ss.writeString("GET http://dlang.org HTTP/1.1\r\n" "Host: dlang.org\r\n" "Connection: close\r\n" "\r\n"); while (! ss.eof) { writeln(ss.readLine()); } } How should it look with ranges instead of socketstream? I thought I understand ranges in general, but I can't figure out how they can be applied to this case.
Nov 29 2015
On Sunday, 29 November 2015 at 18:00:34 UTC, tired_eyes wrote:On Sunday, 29 November 2015 at 16:10:22 UTC, Alex Parrill wrote:In case someone is still looking for the answer, just like me. It will be something like that: import std.stdio; import std.socket; enum receiveBufferLength = 1024; void main() { auto socket = new TcpSocket(new InternetAddress("dlang.org", 80)); scope(exit) socket.close(); socket.send("GET http://dlang.org HTTP/1.1\r\nHost: dlang.org\r\nConnection: close\r\n\r\n"); string response; char[receiveBufferLength] receiveBuffer; while (true) { auto received = socket.receive(receiveBuffer[0 .. receiveBufferLength]); response ~= receiveBuffer[0 .. received]; if (received == 0) break; } write(response); }std.stream, and the stream interface in general, is deprecated in favor of ranges, which are more generic and flexible.Could you please give a small example? Consider this minimal app: import std.stdio; import std.socket; import std.socketstream; void main() { auto socket = new TcpSocket(new InternetAddress("dlang.org", 80)); scope(exit) socket.close(); auto ss = new SocketStream(socket); ss.writeString("GET http://dlang.org HTTP/1.1\r\n" "Host: dlang.org\r\n" "Connection: close\r\n" "\r\n"); while (! ss.eof) { writeln(ss.readLine()); } } How should it look with ranges instead of socketstream? I thought I understand ranges in general, but I can't figure out how they can be applied to this case.
Sep 03 2016