TCP Node port in use not caught properly

pull/183/head
Nick O'Leary 2014-03-17 16:09:07 +00:00
parent 015adb3dfd
commit f666b0e6f9
1 changed files with 33 additions and 13 deletions

View File

@ -154,13 +154,23 @@ function TcpIn(n) {
node.log(err);
});
});
server.listen(node.port);
node.log('listening on port '+node.port);
this.on('close', function() {
this.closing = true;
server.close();
node.log('stopped listening on port '+node.port);
server.on('error', function(err) {
if (err) {
node.error('unable to listen on port '+node.port+' : '+err);
}
});
server.listen(node.port, function(err) {
if (err) {
node.error('unable to listen on port '+node.port+' : '+err);
} else {
node.log('listening on port '+node.port);
node.on('close', function() {
node.closing = true;
server.close();
node.log('stopped listening on port '+node.port);
});
}
});
}
@ -272,13 +282,23 @@ function TcpOut(n) {
}
}
});
server.on('error', function(err) {
if (err) {
node.error('unable to listen on port '+node.port+' : '+err);
}
});
server.listen(node.port);
node.log('listening on port '+node.port);
node.on('close', function() {
server.close();
node.log('stopped listening on port '+node.port);
server.listen(node.port, function(err) {
if (err) {
node.error('unable to listen on port '+node.port+' : '+err);
} else {
node.log('listening on port '+node.port);
node.on('close', function() {
server.close();
node.log('stopped listening on port '+node.port);
});
}
});
}
}