I use QTcpSocket for getting information from server.
From my side it’s necessary to connect and wait for bytes from server, and get them.
I create QTcpSocket. Connect it to host. Begin getting data, that’s ok. But when, for example, I pull out the ethernet cable, there is no difference with the socket object.
I tried to connect such signals as QAbstractSocket::error() and QAbstractSocket::stateChange(), but none gives me anything at the moment of disconnection.
My task is to wait some seconds and try to reconnect, until I get a connection again.
Any advice?
I had a same problem while programming client and server project.
I used SIGNAL -> disconnected() which is emitted immediately by the client when it is disconnected.
connect(client, SIGNAL(disconnected()), this, SLOT(DisconnectMessage()));
Please try using it.