I am writing Qt TCP/IP client. I want to check the connection state with server before send data to sever. As far my knowledge I can do this by following methods
- Use a bool 'ConnectionState', set this variable when connected with sever and reset this variable on disconnected() signal. Now before sending data to server (client->write()) check the value of this variable.
- use this 'client->state() == QTcpSocket::ConnectedState' way to check the connection state.
Which is good practice. Or any other method to this.
Thanks In advance.