Which statement best explains how WebSockets differ from traditional HTTP for real-time communication?
Think about how connections are maintained during communication.
WebSockets create a single, persistent connection that stays open, enabling both client and server to send messages anytime. HTTP opens and closes connections for each request and response.
What is the purpose of the WebSocket handshake in establishing a connection?
Consider how WebSockets start from an HTTP connection.
The handshake upgrades a normal HTTP connection to a WebSocket connection by exchanging headers that confirm both sides support WebSockets.
You are building a chat app that requires instant message delivery between users. Why is using WebSockets a better choice than HTTP polling?
Think about how often data is sent and how connections are managed.
WebSockets keep a connection open so messages can be sent instantly without the delay of repeated HTTP requests, reducing latency significantly.
What happens to an active WebSocket connection if the network temporarily disconnects and then reconnects?
Consider how persistent connections behave when interrupted.
WebSocket connections do not automatically resume after network loss; the connection closes and the client must reconnect to continue communication.
Which of the following is the most important security measure when using WebSockets in a public web application?
Think about how data travels over the network and how to protect it.
Using Secure WebSockets (wss://) encrypts the data sent over the connection, protecting it from interception and tampering.