Basics of web socket
WebSocket is a communication protocol that provides full-duplex (two-way) communication channels over a single TCP connection. It is commonly used for real-time web applications where low latency and efficient communication are required, such as chat applications, online gaming, live notifications, and stock market updates.
Key Features of WebSocket:
Full-Duplex Communication:
Both the client and server can send and receive messages independently at the same time.
This contrasts with HTTP, where the client must always initiate communication.
Persistent Connection:
WebSocket keeps the connection open, reducing the overhead of repeatedly opening and closing connections, as seen with HTTP requests.
This makes it highly efficient for applications requiring continuous data exchange.
Low Latency:
Messages can be sent and received in near real-time due to the persistent nature of the connection.
Lightweight:
The protocol uses a small header after the initial handshake, minimizing data overhead compared to HTTP.
Bidirectional Messaging:
Either party (client or server) can send messages whenever needed without waiting for a request.