A web socket is an interaction between a web browser and a web server transferring realtime data.
A handshake starts with a request from a client and a response from the server. Once extablised, the communication between the client and the server switches to a bidirectional protocol.
Request
It handles the connection, disconnection, and other events in the socket object.
answer
It creates and fire custom events.
WebSocket is a communication protocol and Socket.IO is a library that uses WebSocket and provides an interface.
When we need to provide event-based communication between browser and server that supports broadcasting and can be estrablised with proxies and load balancers.
Whe we want the full duplex connection over TCP.