I need to send and receive very large data using udp. Unfortunately udp provides 8192 bytes per diagram, so there is need to divide data into smaller pieces.
I’m using Qt and QUdpSocket. There is a QByteArray with length of 921600 I want to send to client. I want to send 8192 bytes each time.
What is the fast way to split a QByteArray?
You can use the
QByteArray.mid(int start, int len)method (see documentation here) to get a QByteArray of lengthlenstarting fromstart.Just make
lenyour datagram size and start with0*len,1*len,2*len, … until everything is sent.