title: Qt C++ Console Server, Wait for socket connection & accept input at same time?
body: <p>I am writing a server as a Qt console application. I have the server set up to wait for a socket connection, but I also need to allow a user to input commands into the server for managing it. Both are working independently. However, the problem I ran into is that when I'm in a while loop accepting and processing input commands, the server doesn't accept connections.</p>
  
  <p>I have a Socket class, and in its constructor, I have:</p>
  
  <pre><code>connect(server,SIGNAL(newConnection()),this, SLOT(newConnection()));
  </code></pre>
  
  <p>Right under that in the constructor, I call a function that has a more in-depth version of this for getting commands from the user:</p>
  
  <pre><code>QTextStream qin(stdin, QIODevice::ReadOnly);
  QString usrCmd;
  
  while(usrCmd != "exit" &amp;&amp; usrCmd != "EXIT") {   
      //Get command input and process here
  }
  </code></pre>
  
  <p>Inside newConnection(), I just accept the next connection and then use the socket.</p>
  
  <pre><code>QTcpSocket *serverSocket = server-&gt;nextPendingConnection();
  </code></pre>
  
  <p>How can I make it so the socket can wait for connections <strong>and</strong> wait for user-inputed commands at the same time?</p>