title: QTcpSocket, wait for server
body: <p>I am making simple client server program using QTcpServer, QTcpSocket with out using thread,in fedora. I want to make my application, independent of sequence of what is running first, client or server.My application is running  well when I start server first, but I am not getting any way to make client wait, while server is not start and connect with serve as server start. I used waitForConnection() but it is not helping.
  Please give some suggestions. </p>
  
  <pre><code>TcpClient::TcpClient(QWidget *parent) : QMainWindow(parent),
  ui(new Ui::TcpClient) 
  
  {
  ui-&gt;setupUi(this);
  tcpSocket= new QTcpSocket(this);
  tcpSocket-&gt;connectToHost(QHostAddress::LocalHost,6178);     
  connect(tcpSocket, SIGNAL(connected()), this, SLOT(sendRequest()));
  connect(tcpSocket, SIGNAL(disconnected()),this, SLOT(connectionClosedByServer()));      
  connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(error())); 
  .
  .
  ..
  
  }
  
  void TcpClient::error() 
  
  { 
   ui-&gt;lStatus-&gt;setText(tcpSocket-&gt;errorString());
   closeConnection(); 
   tcpSocket-&gt;connectToHost(QHostAddress::LocalHost,6178);
   } 
  </code></pre>