~/ learn/ comp-348/ cards/ What a protocol specification must pin down
1 of 4

Pin framing and encoding in code: explicit CRLF, explicit charset, explicit flush.

Pin framing and encoding in code: explicit CRLF, explicit charset, explicit flush.

Answer

final String CRLF = "\r\n"; Writer out = new BufferedWriter(new OutputStreamWriter( socket.getOutputStream(), StandardCharsets.US_ASCII)); out.write("200 Poem of the Day" + CRLF); out.flush();

Three of the eight decisions, made visible in four lines. The charset is named rather than inherited from the platform, the terminator is the protocol's own CRLF rather than the platform separator, and the flush is what actually puts the bytes on the wire — a BufferedWriter that is never flushed is a hang waiting to happen.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/7f293e7c-f192-45f0-9ccb-fb8987cedb12/flashcard utf-8 LF