Two views of one socket: the raw stream and a Writer over it
Two views of one socket: the raw stream and a Writer over it
Answer
OutputStream raw = new BufferedOutputStream(client.getOutputStream()); Writer out = new OutputStreamWriter(raw, StandardCharsets.US_ASCII); Reader in = new InputStreamReader( new BufferedInputStream(client.getInputStream()), StandardCharsets.US_ASCII);
The `Writer` wraps `raw`, so both write into the same buffer and the same socket — there is one destination, not two. Both charsets are pinned to US-ASCII because request lines and response headers are protocol text, and protocol text is never platform-dependent.
Harold 4e ch9 §A Full-Fledged HTTP Server; ch2 §Readers and Writers