WebSocket
Also called: WebSockets, WS, socket connection, realtime connection.
One connection between the page and the server that stays open and carries messages in both directions at any time. It fits chat, multiplayer games and live cursors, where both sides talk often.
One connection stays open and carries messages both ways: yours go up (↑), Sam's typing and replies come down (↓) without the page asking.
Closed
Say it in a prompt
Build the chat on a WebSocket at wss://example.com/chat: send each message as JSON {"type":"message","text":"..."}, show "Sam is typing…" when a {"type":"typing"} frame arrives, send a ping every 30 s, and when the socket closes, reconnect after 1 s, 2 s, then 4 s (at most 30 s) and resend any message the server did not confirm. Seen on
You might describe it as
- chat where messages show up instantly on both sides
- see when the other person is typing
- a connection that stays open so both sides can talk
Not to be confused with
- Server-sent events (SSE)
A WebSocket lets both sides send at any time; server-sent events only push from the server to the page.