🎓 BookMCQ
← Back to 25. Introduction to Application Layer

📝 Concurrent communication in networking (8 MCQs)

Serving Multiple Client Activities at the Same Time

Concurrent network communication allows a server to make progress on multiple client interactions during overlapping periods. A server may create a thread or process for each accepted connection, use a worker pool, or employ event-driven I/O. Concurrency improves responsiveness when clients wait for network data or perform operations of different durations. Several handlers can remain active while individual clients wait for responses.

Threads, Processes and Event-Driven Designs

A process-per-client design isolates client handling in separate processes, while a thread-per-client design shares a process address space. Worker pools limit the number of active workers, and event-driven designs monitor many sockets for readiness. Each method trades implementation complexity, resource use, and scheduling behavior. The selected approach determines how execution state and socket ownership are managed.

Accepting Connections and Scheduling Client Work

A TCP server continues accepting connections and assigns each connected socket to a worker or event loop. Each handler receives data, parses requests, produces responses, and manages closure independently. With UDP, concurrent designs may dispatch received datagrams to workers, but the application must preserve request context when responses are generated later.

Two Clients Making Overlapping Requests

A web server receives a request from client A that triggers a database lookup, then accepts client B while A's lookup is still pending. A worker can process B without waiting for A's database operation to finish. Both responses are returned to their respective client sockets, avoiding cross-delivery. The scheduler can switch workers while either operation waits for input.

Shared State, Synchronization and Capacity

Concurrent handlers may access shared counters, files, caches, or database connections. Unsynchronized updates can cause race conditions, while excessive threads consume memory and scheduling time. A robust design bounds worker resources, protects shared data, handles disconnected clients, and applies timeouts so stalled peers do not occupy resources indefinitely. Locks or other coordination mechanisms protect updates that must remain consistent.

Concurrency Misconceptions

'Concurrent means instructions execute simultaneously on separate CPUs' is too narrow because concurrency can interleave tasks on one processor. 'Threads cannot share data' is false because threads in one process share address space. 'More workers always improve throughput' ignores contention, memory limits, and scheduling overhead. Concurrency describes overlapping task progress, not necessarily simultaneous execution.

Comparing Iterative and Concurrent Server Behavior

For examinations, compare how an iterative server handles one client at a time with thread, process, pool, and event-driven approaches. Trace assignment of accepted sockets to handlers, identify shared-state risks, and explain race conditions and synchronization. Evaluate responsiveness alongside resource consumption rather than assuming concurrency always increases capacity. Also consider fairness, queue growth, and how failed workers are recovered.

Concurrent Server Design Terms

  • Concurrency - Overlapping progress of multiple activities.
  • Thread - Execution path within a process.
  • Process - Program instance with its own resources.
  • Race condition - Result depends on unsynchronized operation timing.
  • Worker pool - Fixed group of reusable request handlers.
  • Synchronization - Coordination that protects shared operations.
2
Easy
4
Medium
2
Hard

📝 All Concurrent communication in networking MCQs

Q1. In peer-to-peer (P2P) networks, which term describes the direct communication between two nodes without an intermediate server?

A.Client
B.Server
C.Endpoint ✅
D.Broker
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The term “Endpoint” denotes a node that can both send and receive data directly, eliminating the need for a central server. In P2P architectures each participant acts as an endpoint, enabling symmetric communication and resource sharing across the network.

Q2. If a client initiates a request before establishing a TCP connection, what is the most likely outcome?

A.Request is queued
B.Connection is reset
C.Request is delivered after handshake
D.Error is returned ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: TCP requires a three‑way handshake before any application data can be transmitted. Sending data beforehand violates the protocol, so the operating system will reject the request and return an error to the application, preventing premature transmission.

Q3. Which statement best differentiates concurrency handling in client‑server versus P2P architectures?

A.Client‑server uses a central thread pool
B.P2P relies on decentralized event loops ✅
C.Both use identical concurrency models
D.P2P cannot support concurrent sessions
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: P2P systems typically employ decentralized event‑driven loops, allowing each peer to manage many connections asynchronously. In contrast, traditional client‑server designs often use a central thread pool or process per request, leading to different scalability and resource‑management characteristics.

Q4. In a concurrent P2P file‑sharing application, how does employing non‑blocking I/O improve throughput?

A.It reduces network bandwidth
B.It allows a node to handle multiple connections without waiting for each read/write to complete ✅
C.It encrypts data automatically
D.It limits connections to one at a time
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Non‑blocking I/O lets a single thread issue read/write calls that return immediately, enabling the node to service many sockets concurrently. By not stalling on slow operations, the application can keep data flowing, increasing overall throughput and resource utilization.

Q5. When a NAT device maps multiple internal sockets to external ports, which condition can cause a collision that disrupts concurrent connections?

A.External port range is exhausted
B.Two internal sockets request the same external port simultaneously ✅
C.NAT translates IP addresses only
D.NAT adds latency
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: NAT maintains a translation table keyed by internal address, port, and external port. If two internal sockets request the identical external port at the same time, the NAT cannot uniquely map both, leading to a collision that drops or misroutes traffic for one of the connections.

Q6. Evaluate the impact of using a thread‑per‑connection model versus an asynchronous event‑driven model on scalability in a concurrent P2P messenger.

A.Thread‑per‑connection scales better because each thread handles one connection
B.Asynchronous model scales better because it avoids the overhead of creating many threads ✅
C.Both use equal scalability
D.Thread‑per‑connection uses less memory
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The asynchronous event‑driven model eliminates the need for a separate thread per socket, reducing context‑switch overhead and memory consumption. As the number of simultaneous peers grows, this model can sustain many more connections than a thread‑per‑connection approach, which is limited by OS thread resources.

Q7. Synthesize a design where a P2P application simultaneously supports real‑time chat and bulk file transfer. Which concurrency mechanism best ensures low latency for chat while maintaining high throughput for files?

A.Single queue with round‑robin scheduling
B.Separate priority queues with a hybrid thread pool, giving chat tasks higher priority ✅
C.Only use async I/O for all traffic
D.Allocate a dedicated thread per file transfer
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Using separate priority queues lets the system assign higher scheduling priority to chat messages, ensuring they are processed quickly. A hybrid thread pool can then handle both high‑priority chat and lower‑priority file‑transfer tasks, balancing latency and throughput without starving either traffic type.

Q8. Apply the principle of rendezvous in concurrent communication to explain how two peers can synchronize file chunk exchange without a central coordinator.

A.Peers use a central server to announce availability
B.Peers exchange sequence numbers and wait for matching request/response pair ✅
C.Peers randomly send data until success
D.Peers cannot synchronize without a broker
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Rendezvous requires each peer to send a request containing a sequence identifier and then wait for the counterpart’s matching response. By aligning these identifiers, both sides know precisely which chunk to send or receive, achieving synchronized exchange without relying on any external coordination service.

🔗 Related Topics (MCQs)