SocketStream exceptions and disconnect handling

Pedro Lacerda pslacerda at gmail.com
Wed Mar 7 09:26:41 PST 2012


Hi all,

I'm trying to handle disconnections transparently on SocketStream. I
thought something like this:

void send(ubyte[] buffer) in { assert(buffer.length > 0); }
body {
    if (!stream.isAlive) connect();
    auto sent = stream.write(buffer);
    if (sent == 0)
        throw new Exception("Error while writing");
}

But that's impossible because isAlive doesn't exists for SocketStream and I
can't get the underlying socket object. Is that something missing or should
I handle it differently?

Pedro Lacerda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120307/45af4eeb/attachment-0001.html>


More information about the Digitalmars-d-learn mailing list