var hiredis = require("./build/default/hiredis"),
    net = require("net");

exports.Reader = hiredis.Reader;
exports.createConnection = function(port, host) {
    var s = new net.Stream();
    var r = new hiredis.Reader();
    var _write = s.write;
    s.connect(port || 6379, host);

    s.write = function() {
        var i, args = arguments;
        _write.call(s, "*" + args.length + "\r\n");
        for (i = 0; i < args.length; i++) {
            var arg = args[i];
            _write.call(s, "$" + arg.length + "\r\n" + arg + "\r\n");
        }
    }

    s.on("data", function(data) {
        var reply;
        r.feed(data);
        try {
            while((reply = r.get()) !== undefined)
                s.emit("reply", reply);
        } catch(err) {
            r = null;
            s.emit("error", err);
            s.destroy();
        }
    });

    return s;
}


@@ -171,21 +171,45 @@
 = ne
-w net.Stream(
+t.createConnection(port %7C%7C 6379, host
 );%0A 
@@ -270,43 +270,8 @@
 ite;
-%0A    s.connect(port %7C%7C 6379, host);
 %0A%0A  

use net.createConnection