I'm trying to check if websites repond to me. So, I have a list and I'm sequentially testing them with QNetworkAccessManager like shown below. The problem is that although I'm trying, the process may still be a bit asyncroneous, meaning that the replyFinished() function is not called without a lag or too late or while the next URL is already tested. I know this because I sometimes get wrong results. Does anyone have ideas, I'd be very thankful.

This is my main function:
Qt Code:
  1. QUrl url; QNetworkAccessManager manager;
  2.  
  3. for(int y=1; y<100+1; y++){
  4.  
  5. tT.setSingleShot(true);
  6. connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
  7. connect(&manager, SIGNAL(finished(QNetworkReply*)), &q, SLOT(quit()));
  8.  
  9. QNetworkReply *reply = manager.get(QNetworkRequest(url));//this URL is different in every for cycle
  10.  
  11. tT.start(5000); // 5s timeout
  12. q.exec();
  13.  
  14. if(tT.isActive()){
  15. // download complete
  16. tT.stop();
  17. replyFinished(reply);
  18.  
  19. } else {
  20. // timeout
  21. }
  22. QApplication::processEvents();
  23. }
  24.  
  25. QApplication::processEvents();
  26.  
  27. }
To copy to clipboard, switch view to plain text mode 

This is my replyFinished() slot:
Qt Code:
  1. void MyClass::replyFinished(QNetworkReply* reply)
  2. {
  3.  
  4. QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
  5.  
  6. if (statusCodeV.toInt()!=0){
  7. //report that website reponded
  8. }
  9. else{
  10. //report that website didn't respond
  11. }
  12.  
  13. delete reply;
  14. }
To copy to clipboard, switch view to plain text mode 

Thnaks!