Skip to content

Commit

Permalink
Final update to Node Server
Browse files Browse the repository at this point in the history
Accounts for detecting when client disconnects from server.
  • Loading branch information
SanquezH authored Dec 23, 2024
1 parent face84c commit 47a7cb0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/voip/node VOIP server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 47a7cb0

Please sign in to comment.