我有一个问题是在nodejs net中杀死套接字函数内的所有进程,并且套接字断开后循环是否有办法杀死套接字调用的所有进程?
`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);`
答案 0 :(得分:1)
select * from (
select *,
dense_rank() over (partition by u.id order by c.id) rn,
dense_rank() over (partition by c.id order by v.id) rn2
from users u
left join comments c on c.user_id = u.id
left join votes v on v.comment_id = c.id
) t where rn < 4 and rn2 < 3
应该终止连接。
答案 1 :(得分:0)
如果您想在计算机上试用,请在此处拍摄摘录:
var net = require('net');
net.createServer(function(socket) {
setInterval(function () {//Loop
console.log("tick");
}, 1000);
socket.on('close', function () {
socket.end();
socket.destroy();
console.log("socket closed");
});
}).listen(1000);
socket.end()
和socket.destroy()
并没有杀死net.createServer
内的函数,程序一直在关闭套接字:S