Easy sockets - don't exist yet?
Russel Winder via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 27 02:23:35 PDT 2016
Why not just create a binding to 0MQ and get much, much more than asked
for?
On Mon, 2016-09-26 at 23:40 +0000, Vincent via Digitalmars-d-learn
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?
> 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!
>
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20160927/5846b574/attachment-0001.sig>
More information about the Digitalmars-d-learn
mailing list