title: Is there any more fast\efficient way to run 255 threads like this? CPP
body: <p>I ran 255 threads that trying to connect to some server.
  But its took alot of timr (10 seconds) till the all threads are done.
  If some thread succeed to connect, then the SOCKET I sent by ref, will be filled with the id of that server.</p>
  
  <pre><code>void TryConnect(int octet, SOCKET&amp; soc_returned)
  {
      Client temp_client;
      int first_of_last_octet = getway.find_last_of('.') + 1;
      getway = getway.replace(first_of_last_octet, 3, std::to_string(octet));
      try
      {
          temp_client.GetInfo(getway.c_str(), S_PORT);
          temp_client.CreateSocket();
          temp_client.Connect();
          soc_returned = temp_client.socket_id;
      }
      catch (...)
      {
          std::cout &lt;&lt; octet &lt;&lt; std::endl;
      }
  }
  
  void TryConnectOnSubnet(std::string getway)
  {
      std::vector&lt;std::thread*&gt; threads;
      SOCKET soc_returned;
      for (int i = 1; i &lt; 254; i++)
      {
          std::thread* t = new std::thread(&amp;Client::TryConnect, this, i, std::ref(soc_returned));
          threads.push_back(t);
      }
  
      for (int i = 0; i &lt; 253; i++)
      {
          threads[i]-&gt;join();
      }
  
      std::cin.get();
  } 
  </code></pre>
  
  <p>I dont understand why does it tool too long to do this thing. somebody have any idea?
  BTW, I noticed I didnt activate the <code>delete</code> on this threads.</p>