~/ 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/2d336e2b-f207-45d8-b1b5-00f8662b168d/flashcard utf-8 LF