开发者

QNetworkAccessManager timeout

开发者 https://www.devze.com 2022-12-27 04:23 出处:网络
Presently I am working on an application which sends and receives file from remote server. To do network operation I am using QNetworkAccessManager.

Presently I am working on an application which sends and receives file from remote server. To do network operation I am using QNetworkAccessManager.

To upload a file I am using QNetworkAccessManager::put() and to download I am using Q开发者_运维技巧NetworkAccessManager::get() functions.

While uploading a file I will initialize a timer with time out of 15 sec. if I upload a small file it will complete it within the time out period. But if I try to upload a file which is very large in size get time out. So how to decide time out for uploading of large file.

Same in case of downloading of a large file. I get file in chunk by chunk in readyread() signal. Here also if I download a large file I get time out. So how to decide time out for uploading of large file.


Use the QNetworkReply::uploadProgress() (or downloadProgress) signal to alert you that the operation is progressing. Then, set a timer for 15 seconds after the last uploadProgress/downloadProgress notification (with the timer started when the download/upload commenced.) If the download ever stops, you can cancel the operation 15 seconds after the last update.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号