hi all!
I am having some problem send/receiving large data files, 500 some kbytes.
Code:
forever {
if (nextBlockSize == 0){
if (tcpSocket->bytesAvailable() < sizeof (qint64))
break;
in >> nextBlockSize;
cout <<
"Block size: " <<
QString::number(nextBlockSize
).
toStdString() << endl;
}
if (tcpSocket->bytesAvailable() < nextBlockSize)
{
cout << "Going to break" << endl;
break;
}
...
QDataStream in(tcpSocket);
in.setVersion(QDataStream::Qt_4_5);
forever {
if (nextBlockSize == 0){
if (tcpSocket->bytesAvailable() < sizeof (qint64))
break;
in >> nextBlockSize;
cout << "Block size: " << QString::number(nextBlockSize).toStdString() << endl;
}
if (tcpSocket->bytesAvailable() < nextBlockSize)
{
cout << "Going to break" << endl;
break;
}
...
To copy to clipboard, switch view to plain text mode
output:
New connection
DataReceived
Block size: 611164
Going to break
DataReceived
Block size: 34364522594
Going to break
DataReceived
Block size: 28429488043851784
Going to break
DataReceived
Block size: 23925866948264050
Going to break
DataReceived
Block size: 214753804389
Going to break
DataReceived
Block size: 32651449492373607
Going to break
DataReceived
Block size: 29555366483460197
Going to break
DataReceived
Block size: 32088581143265345
Going to break
DataReceived
Block size: 31525678435008617
Going to break
DataReceived
Block size: 27866439313784937
Going to break
DataReceived
Block size: 31244194868822016
Going to break
DataReceived
Block size: 2624568615239740
Going to break
DataReceived
Block size: 13229757704634480
Going to break
DataReceived
Block size: 13229637444436069
Going to break
DataReceived
Block size: 33777284975165545
Going to break
DataReceived
Block size: 28429445101781072
Going to break
New connection
DataReceived
Block size: 611164
Going to break
DataReceived
Block size: 34364522594
Going to break
DataReceived
Block size: 28429488043851784
Going to break
DataReceived
Block size: 23925866948264050
Going to break
DataReceived
Block size: 214753804389
Going to break
DataReceived
Block size: 32651449492373607
Going to break
DataReceived
Block size: 29555366483460197
Going to break
DataReceived
Block size: 32088581143265345
Going to break
DataReceived
Block size: 31525678435008617
Going to break
DataReceived
Block size: 27866439313784937
Going to break
DataReceived
Block size: 31244194868822016
Going to break
DataReceived
Block size: 2624568615239740
Going to break
DataReceived
Block size: 13229757704634480
Going to break
DataReceived
Block size: 13229637444436069
Going to break
DataReceived
Block size: 33777284975165545
Going to break
DataReceived
Block size: 28429445101781072
Going to break
To copy to clipboard, switch view to plain text mode
the DataReceived output means that the slot readyRead has been triggered, and the first Block size, with "611164 bytes" is the correct number.
I think that I am getting multiple connections but I don't know how to do it better.
I have looked to some examples but all look like mine.
Bookmarks