Problem Statement
What are WebSockets and how do they work in Node.js?
Explanation
WebSockets enable full-duplex (two-way) communication between client and server. They maintain an open connection for real-time updates (e.g., chats, games). Implemented using `ws` or `socket.io` libraries.
Code Solution
SolutionRead Only
const WebSocket=require('ws');
const wss=new WebSocket.Server({port:8080});
wss.on('connection',ws=>ws.send('Connected!'));