I have a problem in attempting to kill all processes inside a socket function in nodejs net: loops keep running after the socket disconnects. Is there a way to kill all processes called by the socket?
net.createServer(function (socket) {
socket.on('end', function () {
//How kill all processes of the current socket ???
});
socket.on('error', function () {
//How kill all processes of the current socket ???
});
i=0;
setInterval(function () {//Waiting other peer for 5sec
i++;
console.log("loop");
if(i>=10){
clearInterval(this);
}
}, 1000);
}).listen(1000);