Exam-style question
Try this first
Compare a normal client-server request-and-response interaction with a WebSocket connection. Explain why WebSockets are useful and give an appropriate type of use.
Model answer
What a good answer should say
- In a normal client-server interaction, the client sends a request message and the server replies with a response message.
- A WebSocket establishes a persistent connection between a web browser and a server over TCP.
- It is full-duplex, so both the browser and server can send data at any time rather than relying only on a separate request followed by a response.
- This makes WebSockets useful where ongoing communication between the browser and server is required, such as an interactive real-time web application.
Explanation
Why this works
The answer should contrast the request-response model with WebSocket persistence and full-duplex communication. It should explain that both parties can send data at any time and identify a suitable ongoing interactive use rather than claiming that WebSockets are a database or replace HTTP entirely.
Common mistake
No common mistake is linked to this question yet.
