nodejs netのsocket関数内のすべてのプロセスを終了させるのに問題があります。ソケット切断後にループが実行され続けると、ソケットによって呼び出されるすべてのプロセスが終了します。Nodejs netでexitソケットを正しく処理する方法
`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);`
Thxをし、しかし、socket.disconectはsocket.io関数です。私の場合、netライブラリからソケットTCPを使用しています。 – han0idx
socket.destroy();を試してみてください。またはsocket.end()です。 [ドキュメントへの参照](https://nodejs.org/api/net.html#net_socket_destroy) –
それを試してみてください:) – han0idx