SocketStream exceptions and disconnect handling

Pedro Lacerda pslacerda at gmail.com
Wed Mar 7 09:29:25 PST 2012


My english is bugged, I mean "handle reconnections transparently". Sorry.

Pedro Lacerda



2012/3/7 Pedro Lacerda <pslacerda at gmail.com>

> 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/21088fcf/attachment.html>


More information about the Digitalmars-d-learn mailing list