~/ learn/ comp-348/ cards/ Writing to a server: request/response turns
1 of 5

Send one dict command: literal CRLF, then the flush that puts it on the wire.

Send one dict command: literal CRLF, then the flush that puts it on the wire.

Answer

Writer out = new OutputStreamWriter( socket.getOutputStream(), StandardCharsets.UTF_8); out.write("DEFINE eng-lat gold\r\n"); out.flush();

The terminator is written literally because the protocol says CRLF, not "a newline". Without the `flush()` the four bytes sit in the writer's buffer and the server never sees a request.

Harold 4e ch8 §Writing to Servers with Sockets

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/45470972-d9fb-4bf3-bdf5-ad264cfb8ca2/flashcard utf-8 LF