Add more safeguards for socket errors

This commit is contained in:
Calvin Montgomery 2015-01-06 10:54:14 -05:00
parent cd22570c40
commit 414cbfdc5d
3 changed files with 37 additions and 11 deletions

View file

@ -217,7 +217,15 @@ module.exports = {
if (id in srv.servers) {
io.attach(srv.servers[id]);
} else {
io.attach(require("http").createServer().listen(bind.port, bind.ip));
var server = require("http").createServer().listen(bind.port, bind.ip);
server.on("clientError", function (err, socket) {
Logger.errlog.log("clientError on " + id + " - " + err);
try {
socket.destroy();
} catch (e) {
}
});
io.attach(server);
}
bound[id] = null;