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?
To avoid unnecessary mail bouncing, I write upfront what I expect
from normal Socket implementation (kind of interface) :
1. Easy to use. No more stupid "UNIX sockets", "TCP types" and so
on. Just simple as this:
// Client side
auto sock = new ClientSocket("google.com", 80);
sock.WriteLine("GET / HTTP/1.0");
sock.WriteLine("Host: google.com");
sock.WriteLine();// empty line sent
// Server side:
auto svc = new ServerSocket("Bound.To.This.IP", 1000);
while ((auto ClientSock = svc.AcceptClient()) !is null) {
auto command = ClientSock.ReadLine();// this is important -
read by line, not idiotic "buffers of bytes"!
ClientSock.WriteLine(command ~ ` yourself!`);
ClientSock.Close();
}
2. Of course integration with std.stream could be nice, it gives
"for free" readLine and other methods.
3. Ability to 'get and forget': hardly all of us wanna deal with
"get portion, write portion to disk, blah". Simple
"sock.ReceiveFile(`http://porno/girl.avi`,
`c:\diploma_work.avi`)" could be enough.
Some kind of "progress report" callback would be nice.
4. SSL/TLS out-of-the-box. In example above it should be same
easy as:
auto sock = new ClientSocket("google.com", 80, Proto.TLS);
At the moment it's all I need, but hope you'll be happy too with
such interface. Sockets are SOOO important, that I cannot believe
we don't have so easy API now. Or if we have, please share!
Thanks everybody!