PDA

View Full Version : tcpscoket not reconnecting



aj2903
2nd March 2009, 05:46
hi,
i'm using tcpscocket & tcpserver in client & server connection.
I have only one client connecting to server.
When first time the application is launched the client is connecting to server, but if connection is disconnected then it is not reconnected . pls help . here is the code :

connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(serverDisConnected()));




void mainwindow::serverDisConnected()
{

tcpSocket->abort();
tcpSocket->close();

tcpSocket->connectToHost("192.168.1.2",5000);

if(tcpSocket->waitForConnected(2000)){
QMessageBox::information(this,"Client-Server Connection","Connected to Server");
else
QMessageBox::information(this,"Client-Server Connection","Client Disconnected ");
}