0

we are trying to implement an application which retrieves data from multiple servers, so we need several QTcpSocket instances in order to manage the connections for each host.

We are facing some decisional "design" problems:

  • should we implement a multi-threading solution to reach the goal? (probably yes)
  • if Yes, should we use a "worker thread" ( e.g as in the QThread example moveToThread(socket_) ) as best solution or there are better ? We need to manage three or more connections simultaneously, so we cannot use waitingForConnection(...) because is a blocking function (from what we understand)
  • what is the best practice for QTcpSocket reconnection? Maybe a QTimer, but what is the best way to use it...?

Thank you in advance!

AD

Andrea D'Ubaldo
  • 137
  • 1
  • 6

1 Answers1

0

Well, I had some design questions just like these, but in my case the main reason was to avoid my connection timing to be delayed by the heavy GUI processing, also, my communication system is thru serial, but apart from it, I think that my model fits pretty well in your case, here is the way i designed it, my questions, and the answers from UmNyobe:

QT QThread with QTimer and QSerial - parenting

Basically, each new instance of my "CommCore" class creates its own Serial, Timer and Thread, and transfers itself and it's children to this Thread, avoiding that the GUI processing interferes in the communication timing.

Gustavo Laureano
  • 556
  • 2
  • 10