How to I transfer file with size more than 65KB?
I am trying to send a file, it has most size 65KB, but after receive it, it has only 65KB and the remainder of file is lost. Can someone help me?
- if (! connected)
- QFile fileSend(filename);
- if (fileSend.open(QIODevice::ReadOnly))
- QByteArray data(fileSend.readAll());
- Message msg;
- << filename << version);
- QByteArray block;
- out << (quint32)0;
- out << msg;
- out << (quint32)(block.size() - sizeof(quint32));
- quint64 xx = 0;
- while (xx < data.size())
- xx += tcpSocket->write(data);
- qWarning("data.size(): %u, xx: %u \n", data.size(), xx);
- // tcpSocket->write(block);
Well, if you start the discussion on how to do best. The question is also, do you really want to send just a big file? For a couple of 100 kB that is acceptable. For a couple of MB it might make sense to spend a little more thinking. Memory is not as expensive anymore as it was, but ultimately one is always reaching the boundaries.
So cutting the file into chunks on both is certainly a good thing to think about.