🎓 BookMCQ
← Back to 26. Standard Client Server Protocols

📝 How FTP data transfer works (14 MCQs)

Preparing a File Transfer over FTP

An FTP transfer begins with a working control session and a command that identifies the requested file or destination. The client and server negotiate data-connection details and transfer representation. A separate data stream then carries the file bytes or directory listing, while the control connection reports preliminary and final status. This design separates session control from the potentially lengthy movement of file contents.

Representation Type and Transfer Parameters

Before transfer, the client can select TYPE A for ASCII-oriented text handling or TYPE I for image/binary mode. It also selects active or passive data setup. The server checks permissions and file availability, prepares the data process, and accepts or initiates the second TCP connection according to the selected mode.

Opening the Data Path and Moving File Bytes

For RETR, the client names a remote file; for STOR, it identifies a destination to receive uploaded data. The server returns a preliminary reply, transfers bytes over the data connection, and closes or completes that connection. A final reply on the control channel reports whether the operation completed successfully. The server reports progress so the client can distinguish setup from completed transfer.

Downloading a File in Binary Mode

A client downloads archive.zip using TYPE I and PASV, receives a server-advertised data port, and opens a second TCP connection. After RETR archive.zip and a preliminary response, the server transmits the original byte sequence. A final 226 reply confirms completion after the data stream ends. The sequence demonstrates why a successful command and completed data transfer are separate events.

Transfer Completion and Control-Session Continuity

The control connection can remain open after a data connection closes, permitting another command without repeating login. File size, access permission, available storage and network interruption can affect the result. TCP provides reliable delivery within a connection, but FTP command success and file-system correctness remain application-level concerns. This separation supports repeated operations within one authenticated control session.

Mistakes About FTP Transfer Stages

'The file travels through the control channel' confuses commands with data; file bytes use the data connection. 'Every transfer closes the FTP session' is false because typically only its data connection closes. 'ASCII mode is suitable for every file' is wrong because binary files can be altered by text conversions; TYPE I preserves arbitrary bytes.

Tracing RETR and STOR Operations

When tracing a transfer, identify the command, selected TYPE, connection mode, endpoint that opens the data socket, preliminary reply, data movement and final reply. Distinguish a successful login from a successful transfer, and compare RETR with STOR. In scenario questions, locate whether a failure occurs during setup, transmission or completion.

FTP Transfer Process Terms

  • TYPE A - Selects ASCII-oriented text handling.
  • TYPE I - Selects binary file representation.
  • RETR - Requests a server-side file download.
  • STOR - Uploads file data to server storage.
  • Data connection - Carries the transferred bytes.
  • 226 - Reports successful transfer completion for the data channel.
5
Easy
7
Medium
2
Hard

📝 All How FTP data transfer works MCQs

Q1. What two components uniquely identify a socket address in the TCP/IP suite?

A.IP address and port number ✅
B.MAC address and subnet mask
C.Hostname and DNS record
D.Protocol type and checksum
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A socket address is defined by the host's IP address, which identifies the machine on the network, and a port number, which distinguishes the specific process on that host. Together they provide a unique endpoint for communication, whereas MAC addresses, hostnames, or protocol types alone are insufficient for socket identification.

Q2. Which OSI layer directly interacts with the socket interface presented to application programs?

A.Transport
B.Network
C.Application ✅
D.Physical
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The socket interface is exposed to applications at the Application layer, allowing programs to read from and write to sockets as if they were files. Although sockets rely on Transport‑layer protocols like TCP or UDP, the actual API calls are made from the Application layer, making this the correct answer.

Q3. If a client changes its local port number while keeping the same remote IP and port, what happens to the existing TCP connection?

A.The connection continues unchanged
B.The connection is terminated by the OS
C.A new TCP connection is created with the new port ✅
D.There is no effect on data flow
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Changing the local port modifies the four‑tuple that identifies a TCP connection (source IP, source port, destination IP, destination port). Since the original four‑tuple no longer matches, the OS treats the change as a new connection attempt, leaving the original connection intact until it is closed.

Q4. Compare a socket to a UNIX file descriptor. Which statement is accurate?

A.They are exactly the same abstraction
B.A socket adds network semantics to the descriptor ✅
C.A file descriptor adds network semantics to the socket
D.Sockets cannot be used for I/O operations
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Both sockets and file descriptors are integer handles, but a socket extends the concept by incorporating network addressing (IP and port) and protocol semantics, enabling communication over a network. A file descriptor refers to local resources like files or pipes, lacking inherent network capabilities.

Q5. Why are two sockets required for a client‑server interaction?

A.One socket can handle both directions simultaneously
B.Each direction of communication uses its own socket endpoint ✅
C.Sockets are only needed on the server side
D.Sockets replace the need for IP addresses
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: In TCP/IP, a socket represents one endpoint of a connection. To achieve full‑duplex communication, the client and server each create a socket, providing a local address (IP + port) and a remote address. This pair of sockets enables independent sending and receiving of data across the network.

Q6. A server is listening on port 80. Another process on the same host tries to bind to port 80. What will the operating system do?

A.Allow both processes to listen on the same port
B.Reject the second bind request with an error ✅
C.Merge the two listening queues into one
D.Automatically assign a new port to the second process
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Port numbers are unique per transport protocol on a host. When a second process attempts to bind to an already‑used port, the OS returns an error (e.g., EADDRINUSE) to prevent address conflicts, ensuring that only one socket can listen on that specific port at a time.

Q7. What is a key advantage of using the socket abstraction instead of raw packet handling for developers?

A.It hides network protocol details while providing reliable streams ✅
B.It eliminates the need for any error checking
C.It forces all communication to be UDP only
D.It makes the application unaware of IP addressing
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Sockets encapsulate the complexities of TCP/UDP, handling tasks such as retransmission, flow control, and ordering, so developers can focus on higher‑level logic. Raw packet handling would require manual construction of headers, checksum calculation, and state management, greatly increasing development effort and potential for bugs.

Q8. A client socket bound to IP 10.0.0.510.0.0.5 and port 50005000 sends data to server IP 10.0.0.1010.0.0.10 port 8080. Which part of the socket address changes for the opposite direction?

A.The remote address becomes the local address
B.The local address becomes the remote address ✅
C.Both addresses stay the same
D.Only the port numbers swap places
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When the server replies, the source of the packet is the server's address (10.0.0.1010.0.0.10:80) and the destination is the client's address (10.0.0.510.0.0.5:5000). Thus, the roles of local and remote addresses are reversed for the return path, while the numeric values themselves remain unchanged.

Q9. During a TCP session, a packet is lost. Which socket‑level mechanism ensures the data is eventually delivered?

A.Acknowledgment (ACK) messages
B.Header checksum verification
C.Retransmission timer triggered by the TCP stack ✅
D.Flow‑control window adjustment
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When a packet does not arrive, the sender's TCP stack detects the missing ACK within the retransmission timeout interval. The retransmission timer then causes the segment to be resent, guaranteeing reliable delivery despite the loss. Checksums only detect corruption, and flow control regulates rate, not loss recovery.

Q10. Which scenario uses a passive open in socket programming?

A.A client initiating a connection to a server
B.A server listening for incoming connections ✅
C.A peer‑to‑peer application establishing a direct link
D.A multicast group joining operation
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Passive open refers to a server calling `listen()` after binding to a port, waiting for incoming connection requests. The server does not initiate the connection; instead, it passively accepts connections from clients, which perform the active open by calling `connect()`.

Q11. How many distinct socket addresses are required for full‑duplex communication between one client and one server?

A.One address shared by both sides
B.Two addresses, one for each endpoint ✅
C.Three addresses, including an intermediate gateway
D.Four addresses, one per direction and per side
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Full‑duplex communication requires each endpoint to have its own socket address (IP + port). The client holds one address, the server holds another, allowing simultaneous sending and receiving. No additional addresses are needed beyond these two endpoints.

Q12. When a server socket is bound to port 0, what does the operating system do?

A.Returns an error indicating an invalid port
B.Assigns a random available port number ✅
C.Uses the default HTTP port 80 automatically
D.Ignores the bind request and leaves the socket unbound
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Binding to port 0 signals the OS to choose an ephemeral port from the dynamic range. The system then assigns a free port, which the application can query (e.g., via `getsockname()`). This technique is useful for services that do not require a well‑known port.

Q13. In a design using non‑blocking sockets with `select()`, which sequence correctly describes handling multiple client connections?

A.Create a blocking socket, call `select()`, then block on `read()`
B.Set sockets to non‑blocking, add them to the `select()` set, and after `select()` returns, read only the ready sockets
C.Use `select()` once, then close all sockets immediately
D.Poll each socket sequentially without using `select()` ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: The proper approach is: (1) set each socket to non‑blocking mode, (2) include them in the file‑descriptor set passed to `select()`, (3) when `select()` indicates readiness, perform non‑blocking `read()` or `write()` on those sockets only, and (4) repeat the loop. This efficiently manages many connections without busy‑waiting.

Q14. Increasing the number of concurrent sockets on a single server process can affect throughput. Which statement is most accurate?

A.Throughput always increases linearly with more sockets
B.Beyond a certain point, OS limits and TCP congestion control cause diminishing returns
C.More sockets guarantee lower latency for each client ✅
D.The number of sockets has no impact on network performance
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: While adding sockets allows more simultaneous clients, the operating system imposes limits on file descriptors, and TCP’s congestion control mechanisms (e.g., cwnd) share bandwidth among flows. Consequently, after a threshold, additional sockets lead to contention, higher context‑switch overhead, and reduced per‑connection performance, yielding diminishing returns.

🔗 Related Topics (MCQs)