You could just increase the size of the buffer. In your case, instead of new data[3072] you could initialize with a size of 9999 or any number that fits your needs. I've tested and seems to work, I misunderstood what you meant with "the maximum limit is 3072".