QFile file(filePath
+ "/" + fileName
);
while (numberOfPackages > 0){
byteArray = file.read(1024);
numberOfPackages--;
printf("Socket disconnected error\n");
return;
}
sock->write(byteArray);
if (sock->bytesToWrite() > 0 && !sock->waitForBytesWritten(10000)){
printf("Socket write error\n");
printf("socket error: %d %s, socket state: %d\n", sock->error(), sock->errorString().toAscii().data(),
sock->state());
return;
}
}
QFile file(filePath + "/" + fileName);
file.open(QIODevice::ReadOnly);
QByteArray byteArray;
while (numberOfPackages > 0){
byteArray = file.read(1024);
numberOfPackages--;
if(sock->state()!=QAbstractSocket::ConnectedState){
printf("Socket disconnected error\n");
return;
}
sock->write(byteArray);
if (sock->bytesToWrite() > 0 && !sock->waitForBytesWritten(10000)){
printf("Socket write error\n");
printf("socket error: %d %s, socket state: %d\n", sock->error(), sock->errorString().toAscii().data(),
sock->state());
return;
}
}
To copy to clipboard, switch view to plain text mode
As I said the second if statement is executed after sending about 50KB of data.
Bookmarks