🎓 BookMCQ
← Back to 27. Network Management

📝 Configuration management in networking (14 MCQs)

📖 From Data Communication and Networks • 27. Network Management • 14 questions available

What is Configuration management in networking?

Configuration management involves tracking and controlling the setup of network devices and software, including inventorying hardware, managing device settings, and ensuring consistent configurations across the network to prevent errors and support troubleshooting.

2
Easy
6
Medium
6
Hard

📝 All Configuration management in networking MCQs

Q1. Which system call is used to accept a new connection from a client?

A.accept ✅
B.bind
C.listen
D.connect
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The `accept` system call extracts the first pending connection request from the listening queue and returns a new socket descriptor for communication. It is distinct from `bind` (which assigns an address), `listen` (which marks a socket as passive), and `connect` (used by clients). Hence, option A is correct.

Q2. What is the purpose of the statement `close(s);` in the server loop?

A.Send pending data
B.Release the socket descriptor ✅
C.Allocate memory for the buffer
D.Bind the address to the socket
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: `close(s);` terminates the connection associated with descriptor `s` and returns the descriptor to the operating system, allowing it to be reused. It does not send data, allocate memory, or bind addresses. Therefore, releasing the socket descriptor (option B) is the correct purpose.

Q3. If the `recv` call returns 1-1, what can be inferred about the state of the TCP connection?

A.The connection was closed gracefully
B.A timeout occurred
C.Data was corrupted during transmission
D.An error occurred and the connection may be broken ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: A return value of 1-1 from `recv` indicates an error such as a network failure, an interrupted system call, or a socket error, suggesting the connection might be broken. It does not mean a graceful closure or timeout, making option D the accurate inference.

Q4. Suppose `maxLen` becomes zero before the loop ends; what will subsequent `recv` calls return?

A.They will block forever waiting for data
B.They will return 1-1 with an error
C.They will return 0 immediately, indicating no more space to store data ✅
D.The program will crash due to an invalid buffer pointer
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When `maxLen` is zero, the buffer length argument to `recv` is zero, so the call returns 0 without reading data. It does not block, nor produce an error, and it does not crash; thus option C correctly describes the behavior.

Q5. If the pointer update `ptr += n;` is omitted, what logical error will occur in later iterations of the receive loop?

A.The loop will become infinite
B.Data will be overwritten or lost because new bytes are written at the start of the buffer each time ✅
C.The pointer will become null and cause a segmentation fault
D.The buffer size will unintentionally increase
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Without advancing `ptr`, each `recv` writes to the same buffer location, overwriting previously received bytes and causing loss of earlier data. The loop still terminates when `recv` returns 0, so the primary issue is data loss, making option B correct.

Q6. Given that the server runs indefinitely, what is the impact on system resources if the socket descriptor `s` is not closed after each client session?

A.File‑descriptor leak leading to exhaustion of available descriptors ✅
B.Memory leak causing the process to grow without bound
C.CPU usage will continuously increase
D.There is no impact; the OS reclaims the descriptor automatically
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Each client session consumes a file descriptor. If `close(s);` is omitted, descriptors accumulate until the process hits the per‑process limit, preventing new connections. This is a classic descriptor leak, making option A the correct impact.

Q7. Compare the error handling strategies used after the `accept` call and inside the `recv` loop. Which approach provides more robust fault tolerance?

A.Both approaches are equally robust
B.The `accept` error handling is less robust because it exits the entire server on a single failure ✅
C.The `recv` loop is less robust because it continues after an error
D.Both are inadequate and should be replaced with retry logic
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The `accept` block aborts the whole server (`exit(1)`) on a single failure, whereas the `recv` loop merely stops reading and proceeds to echo whatever was received. Continuing operation after a recoverable error (as in the `recv` loop) is more fault‑tolerant, so option B correctly identifies the weaker `accept` handling.

Q8. Evaluate the effect of using `while ((n = recv(...)) > 0)` versus a fixed‑count `for` loop for receiving data. Which construct better accommodates variable message sizes?

A.A fixed‑count loop wastes CPU when messages are short
B.The `while` loop may miss data if the sender transmits quickly
C.A `for` loop guarantees the exact number of bytes will be read
D.The `while` loop adapts to the actual number of bytes received, handling variable lengths gracefully ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The `while` condition reads until no more data is available, automatically matching the message length regardless of size. A fixed‑count `for` loop assumes a predetermined byte count, which can either truncate or block unnecessarily. Hence, option D correctly describes the advantage of the `while` construct.

Q9. Differentiate the configuration management implications of hard‑coding the error message string in `perror` versus retrieving it from an external resource file.

A.Hard‑coding makes updates easier because the string is compiled once
B.It has no impact on configuration management practices
C.Hard‑coding makes updates harder because a recompilation is required for every change ✅
D.Using an external file improves security by obscuring error messages
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: When an error message is embedded directly in source code, any modification requires editing the code and rebuilding the binary, increasing effort and risk of regression. Externalizing strings allows changes without recompilation, facilitating smoother configuration management. Therefore, option C accurately captures the implication.

Q10. Assess how compiler optimization that reorders statements could affect the correctness of the `if (s = accept(... ) < 0);` line. Which part of the code is most vulnerable to such reordering?

A.The `accept` line due to missing parentheses and the stray semicolon ✅
B.The `recv` loop because of pointer arithmetic
C.The pointer update `ptr += n;`
D.The final `send` call that echoes data back
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The expression mixes assignment and comparison without parentheses, and the trailing semicolon creates an empty statement. Optimizations that reorder or split the expression can change the intended precedence, making the `accept` line the most vulnerable. Option A correctly identifies this risk.

Q11. Applying the principle of least privilege, which system privileges should the echo server retain after successfully binding its listening socket?

A.Root privileges to modify any system file
B.Administrative privileges to change network settings globally
C.Privileges for all users on the host
D.Only the network privileges required to accept connections on the bound port ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: After binding, the server only needs permission to accept incoming connections on its specific port. Retaining broader privileges (root or admin) violates the least‑privilege principle and increases risk. Thus, option D correctly describes the minimal required privilege set.

Q12. Explain how a version control system supports configuration management for the echo server source code.

A.It tracks changes, enables roll‑backs, and records a history of revisions ✅
B.It improves the program’s execution speed by caching compiled objects
C.It reduces the amount of memory the server uses at runtime
D.It automatically generates network configuration files for the server
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Version control records every modification, allows developers to revert to earlier versions, and maintains a detailed change log—all core aspects of configuration management. The other options describe unrelated effects, making option A the correct explanation.

Q13. In a configuration management plan that includes automated testing, code review, and deployment, at which stage would the missing quotation mark in the `perror` call most likely be detected?

A.During automated unit testing
B.During deployment to production
C.During the code review process ✅
D.During runtime monitoring after release
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: A syntax error such as an unmatched quotation mark prevents successful compilation. While automated tests may catch it, the most reliable detection point is manual or peer code review, where developers examine source for such defects before committing. Hence, option C is the stage most likely to catch the issue.

Q14. Using the concept of immutable infrastructure, how could the deployment of this echo server be redesigned to prevent configuration drift?

A.By using dynamic configuration files that are edited on‑the‑fly
B.By containerizing the server in an immutable image and redeploying the whole image on any change ✅
C.By manually patching the binary on each host whenever a bug is fixed
D.By frequently restarting the server to clear accumulated state
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Immutable infrastructure advocates deploying whole, unchangeable images (e.g., Docker containers). When a change is needed, a new image is built and redeployed, eliminating drift caused by ad‑hoc modifications. Option B accurately reflects this strategy.

🔗 Related Topics (MCQs)