Picture a client whose socket write succeeds, followed by a server that commits the request and loses its reply on the way back. What can the client safely conclude? A successful Linux send() does not establish that the receiving application completed the operation; the manual explicitly warns against treating the call as delivery evidence. [1]

Use that uncertainty as the starting point for a senior or staff engineer transport interview. Your task is to explain where bytes can wait, what each acknowledgment proves, and which component stops waiting when the connection becomes unhelpful. Build the answer around one operation rather than a list of socket options.

Practice scenario: Design a persistent TCP connection that carries document-save requests. Each request has an operation ID, a declared payload length, and a response describing the committed version. The budgets, calculations, and rubric below are illustrative practice material, not production measurements or a published hiring scorecard.

1. Separate bytes accepted, bytes acknowledged, and work committed

Draw the client process, its socket, the peer socket, the server process, and the durable store. Put a different progress marker at each boundary. Linux reports the number of bytes sent through send(); TCP acknowledgment is a separate event. RFC 9293 describes the receiver acknowledging data when its TCP endpoint takes responsibility for delivering it to the application. That responsibility does not establish a database commit. [1] [2]

For this exercise, define the application response to mean that the document and the operation ID have been durably recorded together. If the reply disappears, retain an unknown outcome and resolve it through that operation ID. This is a proposed application contract: transport progress alone cannot supply its commit evidence.

Walk through both possibilities. In one timeline, the request never reaches the application. In the other, the commit happens before the reply is lost. Ask what observation distinguishes them. If your only observation is a later socket error, your answer still needs an application-level resolution path. Keep the discussion on that missing evidence instead of declaring every disconnect a failed save.

Give the byte stream a bounded interpretation

Linux documents TCP as a stream that does not preserve record boundaries. A pair of application writes therefore does not define a pair of receiver messages. The receive API normally returns available data up to the requested amount, rather than waiting to fill the caller's buffer. [4] [3]

Propose a small state machine: accumulate the fixed header, validate its declared length, then accumulate that payload. Choose a maximum frame size and total buffered-byte limit before allocating from a peer-provided length. Preserve leftover bytes for the next frame. Check byte counts and errors before advancing write state, and give one component ownership of serializing outbound frames.

Rehearse with a header arriving one byte at a time and two complete frames arriving in a single read. Those are two representations of the same proposed protocol conversation; your parser should produce the same operations. This keeps the framing discussion focused on stream semantics rather than repeating an HTTP proxy design.

Explain what EOF ends

For a stream socket, Linux recv() returns zero when the peer performs an orderly shutdown. TCP closes its directions independently and permits continued sending in the direction that remains open. [3] [2]

In your protocol, decide whether an inbound EOF is allowed between frames and whether a final response may still be sent. Reject EOF halfway through a declared payload as truncation. Do not turn a clean stream ending into an invented application success: validate the response that your save contract actually requires.

2. Distinguish flow control, congestion control, and application pressure

Label three separate controls on your diagram. The receiver's advertised window limits what the peer is prepared to receive. The sender's congestion window limits outstanding network traffic; RFC 5681 describes transmission as constrained by the minimum of those two windows. Application admission is a third design decision, concerning how much work your service accepts. [5]

Now pause the server's socket reader. Separately, let it continue reading while its document store stalls. Ask where bytes and operations accumulate in each experiment. In the second design, a reader that keeps transferring payloads into an unrestricted application queue has provided no application memory bound. Model that queue explicitly instead of assuming the transport window budgets your work.

On Linux, a send that cannot fit into the socket send buffer normally blocks; with nonblocking I/O it can report EAGAIN or EWOULDBLOCK. Treat that behavior as a signal your sender must handle, with an owner and a stopping condition. [1]

Calculate a bound you can defend

Suppose the exercise allows 2,000 connections and 256 KiB of queued application payload per connection. The arithmetic is 2,000 × 256 KiB = 500 MiB. That is the payload allowance alone. Your proposed budget still needs room for socket buffers, parser state, request objects, and active processing. These are hypothetical inputs, not a memory estimate for any particular runtime.

Add a global queued-byte cap alongside the connection limit. Specify what happens when either cap is reached: stop admitting another frame, reject a new operation through the protocol, or close a connection under an explicitly chosen policy. Settle who releases the reservation after a timeout or parse failure. A byte budget without an ownership rule is an unfinished design.

Then introduce a small save behind a large save. Decide whether ordering is mandatory, whether a request may be rejected before its body is accepted, and how long accepted work may wait. Explain those choices against the document-save requirements. Avoid prescribing larger buffers until you have named the queue and the work they would retain.

3. Assign each timer a specific job

Write the failure question beside each timer. TCP retransmission addresses missing transport acknowledgments. RFC 6298 derives the retransmission timeout from round-trip observations and specifies backing it off by doubling after expiration. That mechanism supplies no application response deadline. [6] [6]

Idle TCP keepalive asks whether an otherwise idle connection's peer responds to probes. RFC 9293 requires keepalive to default to off and, when provided, its default idle interval to be at least two hours. Those protocol requirements are not a claim about the settings your runtime applies. Inspect the deployed configuration. [2]

Be precise about Linux TCP_USER_TIMEOUT

RFC 5482 distinguishes a local, per-connection user timeout from a TCP option that advertises timeout advice to the peer. Do not describe a local socket setting as agreement on an application deadline between both services. [7]

On Linux, a positive TCP_USER_TIMEOUT limits how long transmitted data may remain unacknowledged, or buffered data may remain unsent because of a zero receive window, before TCP closes the connection. It does not change retransmission timing or keepalive probe scheduling. When combined with keepalive, it overrides keepalive's connection-closing decision for keepalive failure. These are Linux semantics, not a portable socket contract. [4]

Return to the case where the server reads and acknowledges the complete save, then stops processing. The design implication is that a timeout concerned with outstanding transport data cannot substitute for the save's response deadline. Name the layer that measures useful application progress and the layer that will stop the wait.

Keep request deadlines distinct from idle activity

For a concrete API example, Go's net.Conn.SetDeadline sets an absolute time for pending and future connection I/O. It remains in effect until changed; the documentation describes implementing idle timeouts by extending deadlines after successful I/O. Consequently, choose deliberately between a fixed operation deadline and a policy refreshed by activity. [8]

Suppose the save has an illustrative 1.5-second budget and spends 400 milliseconds waiting for admission. Its remaining allowance is 1.1 seconds, not another 1.5 seconds. Decide how connection setup, writing, and waiting for the response share that allowance. For a connection carrying concurrent operations, assign request cancellation to the protocol owner; avoid letting an individual request casually reset shared socket policy.

Make that ownership concrete. In this exercise, let the connection owner track frame progress and an operation table track unresolved saves. Propose retiring a connection if a write timeout leaves an incomplete outbound frame, then explain how every affected waiter receives its own unresolved result. Alternatively, defend a way to finish the frame safely. The point is to account for the remaining bytes before the next save uses that stream.

The same distinction applies above TCP. gRPC's guidance says clients have no deadline by default and recommends setting one explicitly. It also makes the server application responsible for stopping work it spawned after cancellation. A gRPC HTTP/2 keepalive checks the connection, while health checking concerns the service. Neither replaces a save result. [9] [10]

4. Rehearse failures that distinguish your contracts

Turn the diagram into a small test plan before tuning anything. Use the following sequence as an author-proposed interview drill. For each case, predict the observable event, the queue that grows, the timer that ends the wait, and the application's final knowledge:

  1. Split and combine input: deliver partial headers and multiple frames together; verify parser state and bounded allocation.
  2. Stop reading: hold the peer reader and verify the sender's bounded waiting and cleanup policy.
  3. Stop processing: read complete saves but suspend execution; verify the application deadline and admission cap.
  4. Drop connectivity silently: remove traffic without an orderly close; observe which configured mechanism detects the problem.
  5. Lose the reply after commit: verify that the client preserves uncertainty and resolves the operation ID.
  6. Half-close or truncate: test a valid directional shutdown separately from EOF inside a frame.

For an isolated Linux harness, netem supports impairments including delay, loss, duplication, and reordering. Its manual documents kernel timing limitations and recommends receiver-ingress placement for realistic TCP performance tests. Use an application failpoint for the precise “commit, then lose reply” timeline; network impairment alone does not select that application state. [11]

Collect evidence at the boundaries you drew: queued application bytes, oldest waiting operation, time blocked on writes, operation deadlines, and server commit records. Where available, add transport observations such as retransmissions and the advertised receive window. State which observation would make you revise your diagnosis. A packet trace and an application timeline should answer different parts of the same question.

As a final exercise, write down two short histories with the same client-visible timeout. In the first, admission rejects the save before execution. In the second, execution commits and the response is suppressed. Define whether lookup returns a recorded rejection, a committed version, or an unknown outcome. A missing record needs an explicit policy for delayed attempts and expired history. Then remove a server log entry and explain what you can still prove. This exposes assumptions about evidence retention without requiring a larger architecture diagram.

Score the explanation, then change one assumption

Use a simple practice rubric: award one point each for distinguishing write/ACK/commit, handling arbitrary stream chunks, specifying EOF and half-close, bounding application memory, and assigning timer ownership. This five-point checklist is a preparation aid. It makes no claim about an employer's evaluation process.

On the next rehearsal, change one assumption: require concurrent saves, introduce a slow reader, or allow a longer recovery window for offline clients. Update the contract and repeat the failure walkthrough. The useful outcome is an explanation you can revise coherently when the interviewer changes the conditions, with every conclusion tied to observable evidence.

Practice explaining the transport boundary

Use Interview Copilot to prepare technical explanations, rehearse follow-up questions, and refine your tradeoffs in a mock interview. Start with the document-save timeline and practice defending its progress markers, memory limits, and timeout ownership.

Start practicing