我正在尝试使用套接字开发一个用于客户端和服务器通信的Qt程序。我需要帮助找出当客户端连接并且服务器试图获取QString时我的服务器崩溃的原因?
我在服务器端有这个代码:
import org.apache.commons.codec.binary.Base64;
...
String base64Data = Base64.encodeBase64String(compressedData);
在客户端:
void Client::onReadyRead() {
qDebug() << "On ready read!";
QDataStream in(mSocket);
in.setVersion(QDataStream::Qt_4_0);
for (;;) {
if(!mBlockSize) {
if (mSocket->bytesAvailable() < sizeof(quint16)) break;
in >> mBlockSize;
}
if(mSocket->bytesAvailable() < mBlockSize) break;
qDebug() << "Package was recieved!";
qDebug() << "Block size: " << mBlockSize;
if(Table::INVALID_ID == mUser.id()) {
QString authStr;
in >> authStr;
qDebug() << "Recieved account data: " << authStr;
}
mBlockSize = 0;
}
}