@Override
		public void run() {
			boolean success = false;
			try {
				StreamRequest streamRequest = readStreamRequest();

				synchronized (blockStreamMap) {
					registration = blockStreamMap.get(streamRequest.streamID);
					if (registration == null || !registration.streamHandle.isPending()) {
						log.error("unexpected stream connection from " + socket.getInetAddress());
						return;
					}
					if (registration.streamHandle.getAuthenticationToken() != streamRequest.authenticationToken) {
						log.error("unauthorized stream connection from " + socket.getInetAddress());
						return;
					}
					blockStreamMap.remove(streamRequest.streamID);
				}

				registration.state = HandlerConnectionState.CONNECTED;

				// serveBlockStream blocks until transfer complete
				registration.streamHandle.serveBlockStream(socket, registration.blockStream);
				registration.blockStream.close();
				success = true;
			}
			catch (IOException e) {
				if (registration != null &&
					registration.state == HandlerConnectionState.READ_HEADER_TIMEOUT) {
					log.error("stream connection failed from " + socket.getInetAddress() +
						": failed to read stream header");
				}
				else if (!(e instanceof EOFException)) { // silent on closed connection
					log.error("file block stream failed from " + socket.getInetAddress() + ": " +
						e.getMessage());
				}
			}
			finally {
				if (!success && (registration != null) &&
					(registration.blockStream instanceof InputBlockStream)) {
					// ensure input stream is closed since it can be terminated by client, 
					// let client handle error if any
					try {
						registration.blockStream.close();
					}
					catch (IOException e) {
						// ignore
					}
				}
				if (!socket.isClosed()) {
					try {
						socket.close();
					}
					catch (IOException e) {
						// ignore
					}
				}
				if (registration != null) {
					registration.state = HandlerConnectionState.CLOSED;
				}
			}
		}
BlockStreamHandler constructor
@param socket accepted/connected socket
Ghidra/Features/GhidraServer/src/main/java/ghidra/server/stream/BlockStreamServer.java