0
0
Computer Networksknowledge~20 mins

WebSockets for real-time communication in Computer Networks - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
WebSocket Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How WebSockets differ from HTTP in real-time communication

Which statement best explains how WebSockets differ from traditional HTTP for real-time communication?

AWebSockets only allow the server to send data, while HTTP allows both client and server to send data.
BWebSockets establish a persistent connection allowing two-way communication, while HTTP opens a new connection for each request-response cycle.
CWebSockets use the UDP protocol, whereas HTTP uses TCP, making WebSockets faster for real-time data.
DWebSockets require a new handshake for every message sent, unlike HTTP which maintains a single handshake.
Attempts:
2 left
💡 Hint

Think about how connections are maintained during communication.

📋 Factual
intermediate
2:00remaining
WebSocket handshake process

What is the purpose of the WebSocket handshake in establishing a connection?

ATo encrypt the data transmitted over the WebSocket connection.
BTo authenticate the client using username and password before opening the connection.
CTo upgrade an existing HTTP connection to a WebSocket connection by agreeing on protocol details.
DTo close the connection after data transfer is complete.
Attempts:
2 left
💡 Hint

Consider how WebSockets start from an HTTP connection.

🚀 Application
advanced
2:00remaining
Choosing WebSockets for a chat application

You are building a chat app that requires instant message delivery between users. Why is using WebSockets a better choice than HTTP polling?

AWebSockets reduce latency by maintaining an open connection, allowing instant message delivery without repeated requests.
BWebSockets guarantee message delivery order, while HTTP polling does not.
CWebSockets use less bandwidth because they compress messages by default, unlike HTTP polling.
DWebSockets automatically store messages on the server for offline users, unlike HTTP polling.
Attempts:
2 left
💡 Hint

Think about how often data is sent and how connections are managed.

🔍 Analysis
advanced
2:00remaining
Impact of network interruptions on WebSocket connections

What happens to an active WebSocket connection if the network temporarily disconnects and then reconnects?

AThe WebSocket connection closes and must be re-established by the client after reconnection.
BThe WebSocket automatically resumes without any action needed from client or server.
CThe server buffers all messages during disconnection and sends them once the client reconnects.
DThe connection switches to HTTP polling mode until the network stabilizes.
Attempts:
2 left
💡 Hint

Consider how persistent connections behave when interrupted.

Reasoning
expert
2:00remaining
Security considerations with WebSockets

Which of the following is the most important security measure when using WebSockets in a public web application?

ADisable all cookies to prevent session hijacking over WebSockets.
BUse HTTP instead of WebSockets to avoid security risks.
COnly allow WebSocket connections from localhost to avoid external attacks.
DUse Secure WebSockets (wss://) to encrypt data and prevent eavesdropping.
Attempts:
2 left
💡 Hint

Think about how data travels over the network and how to protect it.