title: Handling multiple connections using QThreadPool
body: <p>Consider a situation where you need to maintain 256 tcp connections with devices just for ocassionally sending commands. I want to do this in parallel(It needs to block until it gets the response), I'm trying to use QThreadPool for this purpose but I have some doubts if it is possible. </p>
  
  <p>I tried to use QRunnable but I'm not sure how sockets will behave between threads (sockets should be used only in thread that they were created in?)</p>
  
  <p>I'm also worried about efficiency of this solution, I would be glad if somebody could propose some alternatives, not necessarily using QT.</p>
  
  <p>Below I'm posting some snippets of the code.</p>
  
  <pre><code>class Task : public QRunnable {
  
      Task(){
          //creating TaskSubclass instance and socket in it
      }
  
  private:
      TaskSubclass               *sub;
  
      void run() override {
          //some debug info and variable setting...
          sub-&gt;doSomething( args );
          return;
      }
  };
  
  class TaskSubclass {
      Socket         *sock;           // socket instance
      //...
      void doSomething( args )
      {
          //writing to socket here
      }
  }
  
  class MainProgram : public QObject{
      Q_OBJECT
  private:
      QThreadPool *pool;
      Task *tasks;
  
  public:
      MainProgram(){
          pool = new QThreadPool(this);
          //create tasks here
      }
  
      void run(){
          //decide which task to start
          pool-&gt;start(tasks[i]);
      }
  };
  </code></pre>