How to read complete data in QTcpSocket?

前端 未结 4 1564
灰色年华
灰色年华 2020-12-18 02:33

Now the server (implemented with java) will send some stream data to me, my code is like below:

connect(socket, SIGNAL(readyRead()), this, SLOT(read_from_ser         


        
4条回答
  •  半阙折子戏
    2020-12-18 03:05

    Problem is that during tcp data transfer data are send in undefined chunks. If you are trying to read defined block size you have to know in advance expected chunk size ore have a way to determinate when your block ends (something like zero terminated c-string).

    Check if this answer doesn't help you (there is a trick to wait for expected data block).

提交回复
热议问题