@Override
		public void writeBlock(BufferFileBlock block) throws IOException {
			if (blocksRemaining == 0) {
				throw new EOFException("unexpected data in stream");
			}

			out.write(block.toBytes());

			if (--blocksRemaining == 0) {

				// done with compressed stream, force compressed data to flush
				if (out instanceof DeflaterOutputStream) {
					((DeflaterOutputStream) out).finish();
				}

				// perform final handshake after final write
				writeStreamEnd(socket);
				readStreamEnd(socket, false);
			}
		}
<code>ClientInputBlockStream</code> provides the client-side of an
OutputBlockStream which wraps an optionally compressed socket output
stream
Ghidra/Features/GhidraServer/src/main/java/ghidra/server/stream/RemoteOutputBlockStreamHandle.java