Apple·Software Engineer·Technical Phone Screen
- Design and implement a buffered TCP socket reader that handles two message framing strategies: (A) a 4-byte big-endian length prefix where readMessage() returns exactly one complete message per call, and (B) newline-delimited messages via readLine(). The implementation must handle partial reads, back-to-back messages, and EOF correctly across calls, and you need to provide unit tests and a complexity analysis.
“This wrecked me more than I expected.”