Hi,
Sometimes the packets i send over the network seems to get lost O.o
On the local machine all works fine... But not over the internet.
Client:
out << qint64(0) << serverPass << quint16(GET_DB) << database;
out.device()->seek(0);
out << qint64(outBlock.size() - sizeof(qint64));
tcpSocket.write(outBlock);
QByteArray database = inFile.readAll();
QByteArray outBlock;
QDataStream out(&outBlock, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_5);
out << qint64(0) << serverPass << quint16(GET_DB) << database;
out.device()->seek(0);
out << qint64(outBlock.size() - sizeof(qint64));
tcpSocket.write(outBlock);
To copy to clipboard, switch view to plain text mode
Now before i send that packet i check the size od database(QByteArray)and it is correct!
Server code:
/* packet format */
qint64 size2;
quint16 reqType2;
inStream >> size2 >> serverPass2 >> reqType2 >> data2;
QDataStream inStream(tcpSocket);
inStream.setVersion(QDataStream::Qt_4_5);
/* packet format */
qint64 size2;
QString serverPass2;
quint16 reqType2;
QByteArray data2;
inStream >> size2 >> serverPass2 >> reqType2 >> data2;
To copy to clipboard, switch view to plain text mode
now i recive all data correctly except data2 (database) which is a QByteArray with size == 0! But that's not possible, so where is the data? The outgoing array(database) whas not empty...
Is it possible to loose data over tcp??
Bookmarks