WebSocket

What is it?

WebSocket is a communication protocol that provides full-duplex, bidirectional communication channels over a single TCP connection. Unlike HTTP where clients must repeatedly request data (polling), WebSocket maintains a persistent connection allowing both server and client to send messages at any time. This makes it ideal for real-time applications like chat, live notifications, gaming, and collaborative tools.

Practical example

A chat application establishes a WebSocket connection when a user opens the page using new WebSocket and the server URL. When user A types and sends a message, it travels instantly to the server through the open connection. The server immediately broadcasts this message to user B through their connection. Both users see messages appear in real-time without any page refreshing or repeated API calls.

Test your knowledge

How does WebSocket differ from HTTP?

Ask Lex
Lex knows the context of this term and can give targeted explanations, examples, and extra context.
Tip: Lex replies briefly in the widget. For more detail, go to full screen mode.

Learn our language

Learn these terms from real professionals and take your skills further at KdG MCT.

Study at KdG