Socket.io wraps WebSocket với automatic reconnection, rooms, và namespace support.
js
// Server
const io = new Server(httpServer);
io.on('connection', socket => {
socket.on('message', data => { io.emit('message', data); });
});
// Client
const socket = io('http://localhost:3000');
socket.emit('message', 'hello');Rooms cho group chat, namespaces cho tách concerns.
Reconnection tự động.