private void readTillFull(final InputStream inputStream, final byte[] readBuffer)
      throws IOException, PipeConnectionException {
    int alreadyReadBytes = 0;
    while (alreadyReadBytes < readBuffer.length) {
      final int readBytes =
          inputStream.read(readBuffer, alreadyReadBytes, readBuffer.length - alreadyReadBytes);
      // In socket input stream readBytes == -1 indicates EOF, namely the
      // socket is closed
      if (readBytes == -1) {
        throw new PipeConnectionException("Socket closed when executing readTillFull.");
      }
      alreadyReadBytes += readBytes;
    }
  }
Read to the buffer until it is full.

@param inputStream the input socket stream
@param readBuffer the buffer to read into
@throws IOException if any IOException occurs
@throws PipeConnectionException if the socket is closed during listening
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/airgap/IoTDBAirGapReceiver.java