diff --git a/lib/net.js b/lib/net.js index 5489b21910..e624adfcc3 100644 --- a/lib/net.js +++ b/lib/net.js @@ -781,6 +781,7 @@ Socket.prototype.connect = function(options, cb) { if (this.destroyed) { this._readableState.reading = false; this._readableState.ended = false; + this._readableState.endEmitted = false; this._writableState.ended = false; this._writableState.ending = false; this._writableState.finished = false; diff --git a/test/simple/test-net-reconnect.js b/test/simple/test-net-reconnect.js index f4b19977ee..ffc2a73c63 100644 --- a/test/simple/test-net-reconnect.js +++ b/test/simple/test-net-reconnect.js @@ -27,6 +27,7 @@ var net = require('net'); var N = 50; var c = 0; var client_recv_count = 0; +var client_end_count = 0; var disconnect_count = 0; var server = net.createServer(function(socket) { @@ -67,6 +68,7 @@ server.listen(common.PORT, function() { client.on('end', function() { console.error('CLIENT end'); + client_end_count++; }); client.on('close', function(had_error) { @@ -82,5 +84,6 @@ server.listen(common.PORT, function() { process.on('exit', function() { assert.equal(N + 1, disconnect_count); assert.equal(N + 1, client_recv_count); + assert.equal(N + 1, client_end_count); });