diff --git a/lib/Connection.js b/lib/Connection.js index 6bacc05..b9080eb 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -47,6 +47,7 @@ function Connection(config) { config || (config = {}); this._config = { + socket: config.socket, host: config.host || 'localhost', port: config.port || 143, tls: config.tls, @@ -63,7 +64,7 @@ function Connection(config) { : true) }; - this._sock = undefined; + this._sock = config.socket || undefined; this._tagcount = 0; this._tmrConn = undefined; this._tmrKeepalive = undefined; @@ -83,7 +84,7 @@ inherits(Connection, EventEmitter); Connection.prototype.connect = function() { var config = this._config, self = this, socket, parser, tlsOptions; - socket = new Socket(); + socket = config.socket || new Socket(); socket.setKeepAlive(true); socket.setTimeout(0); this._sock = undefined;