QTcpSocket status is incorrect
I am using Qt 4.8.2 (64 bit) on Linux Debian.
I am having problem with socket status. I am client connecting to server, my relevant code snippet is:
QTcpSocket *socket = new QTcpSocket(this);
qDebug() << socket->waitForConnected(10000);
qDebug() << socket->isValid();
qDebug() << socket->state();
I am connecting to server that is local to me and I can disconnect Ethernet cable to it to test both connected and non-connected states. I can tell if I connect by the wait time, if cable is connected to server then waitForConnected takes less than 0.5 seconds and if cable is not connected then waitForConnected times out at 10 seconds.
My problem is I get the same status connected or not. The output of the qDebug is:
And it stays this way if I am really connected or not. When connected I can send data. I also put the last two statements in command button and verified the return status does not change even after several seconds or minutes.
Any help pointing me in the right direction would be most appreciated.