From 47a7cb0bdd08f5818ea93472eea32cc1538879ab Mon Sep 17 00:00:00 2001 From: Sanquez Heard <135459789+SanquezH@users.noreply.github.com> Date: Sun, 22 Dec 2024 19:17:32 -0600 Subject: [PATCH] Final update to Node Server Accounts for detecting when client disconnects from server. --- examples/voip/node VOIP server.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/voip/node VOIP server.js b/examples/voip/node VOIP server.js index de97b125..9a55b14d 100644 --- a/examples/voip/node VOIP server.js +++ b/examples/voip/node VOIP server.js @@ -8,10 +8,14 @@ const VOIPserver = net.createServer((socket) => { socket.on("data", (data) => { socket.write(data); }); - socket.on("end", () => { - console.log('Client disconnected'); + /* + Socket.on(end) will not catch socket closure + due to javascript and java handling sockets differrently, + causing an error. + */ + socket.on("error", (err) => { + console.log(`Client disconnected: ${clientAddress}`); }); - socket.on("error", (err) => {}); }); const PORT = 8080;