title: Qt TCP/IP socket connection check
body: <p>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</p>
  
  <ul>
  <li>Use a bool '<em>ConnectionState</em>', set this variable when connected with
  sever and reset this variable on <em>disconnected()</em> signal. Now before
  sending data to server (client->write()) check the value of this
  variable. </li>
  <li>use this '<em>client->state() == QTcpSocket::ConnectedState</em>' way to check the connection state. </li>
  </ul>
  
  <p>Which is good practice. Or any other method to this.</p>
  
  <p>Thanks In advance.</p>