Hi
The Qt doc says that QAbstractSocket::waitForConnected(-1) will wait until the connection is made.But it returns immediately.The following program shows the problem.

Qt Code:
  1. #include <QtCore>
  2. #include <QtNetwork>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QCoreApplication a(argc, argv);
  7.  
  8. QTcpSocket socket;
  9. socket.connectToHost(QString("127.0.0.1"), 8888);
  10. if(socket.waitForConnected(-1))
  11. qDebug()<<"wait connected";
  12.  
  13. qDebug()<<socket.state();
  14.  
  15. return a.exec();
  16. }
To copy to clipboard, switch view to plain text mode 

In the above program the if condition is supposed to return always true.But it always returns immediately and the socket state is in unconnected state.