title: How to read complete data in QTcpSocket?
body: <p>Now the server (implemented with java) will send some stream data to me, my code is like below:</p>
  
  <pre><code>connect(socket, SIGNAL(readyRead()), this, SLOT(read_from_server()));
  </code></pre>
  
  <p>in the <code>read_from_server()</code>:  </p>
  
  <pre><code>{
      while (socket-&gt;bytesAvailable())
      {
          QString temp = socket-&gt;readAll();
      }
  }
  </code></pre>
  
  <p>but I find that even the server sent me a string with only several characters, the data is truncated, and my function is called twice, thus <code>temp</code> is the never complete data that I want.<br>
  If server send me a longer string, my function may be called three or more times, making me diffficult to know at which time the data is transfered completely.<br>
  So anyone can tell me how to completely receive the data easily, without so many steps of bothering? I'm sorry if this is duplicated with some questions else, I couldn't get their answers work for me. Many thanks!</p>