code: protected int sendBundledMessages(final Message[] buf, final int read_index, final int write_index) {
          int       max_bundle_size=transport.getMaxBundleSize();
          byte[]    cluster_name=transport.cluster_name.chars();
          int       sent_msgs=0;
  
          for(int i=increment(read_index); i != write_index; i=increment(i)) {
              Message msg=buf[i];
              if(msg == NULL_MSG)
                  continue;
              if(msg == null)
                  break;
  
              Address dest=msg.dest();
              try {
                  output.position(0);
                  Util.writeMessageListHeader(dest, msg.src(), cluster_name, 1, output, dest == null);
  
                  // remember the position at which the number of messages (an int) was written, so we can later set the
                  // correct value (when we know the correct number of messages)
                  int size_pos=output.position() - Global.INT_SIZE;
                  int num_msgs=marshalMessagesToSameDestination(dest, buf, i, write_index, max_bundle_size);
                  sent_msgs+=num_msgs;
                  if(num_msgs > 1) {
                      int current_pos=output.position();
                      output.position(size_pos);
                      output.writeInt(num_msgs);
                      output.position(current_pos);
                  }
                  transport.doSend(output.buffer(), 0, output.position(), dest);
                  if(transport.statsEnabled())
                      transport.incrBatchesSent(num_msgs);
              }
              catch(Exception ex) {
                  log.error("failed to send message(s)", ex);
              }
          }
          return sent_msgs;
      }
docs: Read and send messages in range [read-index+1 .. write_index-1]