Real-world mechanisms, state management, edge cases, performance trade-offs, and practical coding.
The TCP 3-way handshake establishes a reliable connection over an unreliable IP network by synchronizing sequence numbers:
SYN bit set to 1. State: SYN-SENT.SYN bit to 1, and acknowledges the client's packet by setting ACK to 1 and the acknowledgment number to $ISN_C + 1$. State: SYN-RECEIVED.ACK bit to 1 and the acknowledgment number to $ISN_S + 1$. State: ESTABLISHED on both sides.TCP connections are full-duplex, meaning each direction must be terminated independently:
FIN bit set, indicating it has no more data to send. Client state: FIN-WAIT-1.ACK. Server state: CLOSE-WAIT; Client state: FIN-WAIT-2. The server can still send data.FIN. Server state: LAST-ACK.ACK and enters the TIME-WAIT state, waiting for $2 \times MSL$ (Maximum Segment Lifetime) before transitioning to CLOSED. Server enters CLOSED immediately upon receiving the ACK.The TIME-WAIT state (usually lasting 2 to 4 minutes) serves two critical purposes:
ACK is lost, the server remains in LAST-ACK and retransmits its FIN. The client must remain active to re-send the ACK.You've completed the 5 free sample questions. Get unrestricted lifetime access to every question, model answer, implementation challenge, and all 27+ technologies for a single payment.
₹399 India / $9 International · One-time settlement · Zero subscription