If I know the tagname of the last tag it should work:
void Interface::readyReadSlot()
{
qDebug() << "readyReadSlot()";
stream>> string;
buffer.write(parcel);
buffer.close();
qDebug
() <<
"parcelsize:" <<
QString::number(parcel.
size());
qDebug() << string;
if(!string.
contains(QRegExp("</EndTag>\n"))){ qDebug() << "wait";
tcpsocket->waitForReadyRead();
}
else
emit dataWritten(block);
}
void Interface::readyReadSlot()
{
qDebug() << "readyReadSlot()";
buffer.open(QIODevice::WriteOnly);
QByteArray parcel = tcpsocket->readAll();
QDataStream stream(&parcel, QIODevice::ReadOnly);
QString string;
stream>> string;
buffer.write(parcel);
buffer.close();
qDebug() << "parcelsize:" << QString::number(parcel.size());
qDebug() << string;
if(!string.contains(QRegExp("</EndTag>\n"))){
qDebug() << "wait";
tcpsocket->waitForReadyRead();
}
else
emit dataWritten(block);
}
To copy to clipboard, switch view to plain text mode
if the server sends exactly one parcel this works fine, but if the server sends more than one parcels, the strings are empty and the buffer writes no data to the bytearray. So maybe the way of sending the data from server is incorrect:
out<< string;
tcpsocket->write(bytearray);
while(!tcpsocket->waitForBytesWritten());
QDataStream out(&bytearray, QIODevice::WriteOnly);
QString string= message;
out<< string;
tcpsocket->write(bytearray);
while(!tcpsocket->waitForBytesWritten());
To copy to clipboard, switch view to plain text mode
Why it didn't work? thank u for your help
Bookmarks