diff --git a/lib/connection.js b/lib/connection.js index 0c5e96f..997b0a7 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -60,6 +60,13 @@ Connection.prototype.connect = function(port, host) { self.emit('end'); }); + this.stream.on('close', function() { + // TODO: avoid emitting 'end' twice ? + // node-0.10 emits both 'end' and 'close' + // for streams closed by the peer + self.emit('end'); + }); + if(!this.ssl) { return this.attachListeners(this.stream); }