private static List<String> receiveLines(SocketChannel socketChannel) throws IOException {
    var buffer = ByteBuffer.allocate(BUFFER_LENGTH);

    buffer.limit(HEADER_LENGTH);
    while (buffer.position() < HEADER_LENGTH) {
      if (socketChannel.read(buffer) < 0) {
        throw new EOFException("Expected " + HEADER_LENGTH + " bytes, got " + buffer.position());
      }
    }
    var marker = buffer.getInt(0);
    if (marker != MARKER) throw new StreamCorruptedException("Invalid marker: 0x" + Integer.toHexString(marker));
    var length = buffer.getShort(4);
    if (LOG.isDebugEnabled()) LOG.debug("receiving: " + length + " bytes");
    buffer.limit(length);
    while (buffer.position() < length) {
      if (socketChannel.read(buffer) < 0) {
        throw new EOFException("Expected " + length + " bytes, got " + buffer.position());
      }
    }

    buffer.position(HEADER_LENGTH);
    var lines = new ArrayList<String>();
    while (buffer.hasRemaining()) {
      var lineLength = buffer.getShort();
      if (lineLength > 0) {
        var bytes = new byte[lineLength];
        buffer.get(bytes);
        lines.add(new String(bytes, StandardCharsets.UTF_8));
      }
      else {
        lines.add("");
      }
    }
    return lines;
  }
private static List<String> receiveLines(SocketChannel socketChannel)