Skip to content

Commit e222f50

Browse files
author
Sandro Santilli
committed
Have Connection also emit 'end' on stream 'close' event
Should fix missing connect callback call with node-0.8 (brianc#534)
1 parent edba02c commit e222f50

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/connection.js

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ Connection.prototype.connect = function(port, host) {
6060
self.emit('end');
6161
});
6262

63+
this.stream.on('close', function() {
64+
// TODO: avoid emitting 'end' twice ?
65+
// node-0.10 emits both 'end' and 'close'
66+
// for streams closed by the peer
67+
self.emit('end');
68+
});
69+
6370
if(!this.ssl) {
6471
return this.attachListeners(this.stream);
6572
}

0 commit comments

Comments
 (0)