I am using 0.10.31 node version. I am facing an issue which looks like a
bug in node. Just wanted to confirm, before filing a bug and work on patch.
Here is the issue:
When the same socket object is used for multiple .connect(), the
socket.localPort is not refreshing with new localPort used by the OS.
Test code:
---------------
In the below code both local port -1 and local port -2 prints the same
local port, but in fact it is using different localPort (when checked by
netstat or lsof).
var net = require('net');
var HOST = '200.xx.xx.204';
var PORT = 7777;
var client = new net.Socket();
client.on('close', function() {
console.log('Connection closed');
//on close just connect again on the same socket object
setTimeout (function() {
connectAgain();
},
5000);
});
client.on('error', function(error) {
console.log(error);
});
client.connect(PORT, HOST, function() {
console.log('local port - 1:' + client.localPort);
// on connect, close the socket. Close socket event will connect again
using the same socket object
client.destroy(); //same with end also
});
function connectAgain() {
client.connect(PORT, HOST, function() {
console.log('local port - 2:' + client.localPort);
console.log('connected to ' + HOST + ':' + PORT);
});
}
Please let me know if this is a bug or expected.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/cff4c089-b632-4344-a5e8-7af45b41ef38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.