The presence of the "accepting" API in Socket seems to indicate that subclassing Socket/TcpSocket is intended to be supported. But I'm just not seeing my way through the twisty maze of pure and @nothrow barriers?

Andy

    import std.socket : TcpSocket, Address, getAddress;

    class WrappedTCP : TcpSocket {
        string label;

        this(string _label) nothrow {
            this.label = _label;
            super();
        }
        override WrappedTCP accepting() nothrow {
            return new WrappedTCP(this.label);
        }
    }
    void main() {
        import std.stdio : writeln;

        auto s = new WrappedTCP("My Label");
        writeln(s.label);
        s.listen(4);
        auto s2 = cast(WrappedTCP)(s.accept());
        writeln(s2.label);
    }

Reply via email to