Not quite. What if data arrives in two parts? You need a while loop that that will call waitForReadyRead() and readAll() until you read all of the data. You will have detect yourself if you read all of the data, to break that loop.
You get only one line, because you call readLine() once. You simply don't read the rest.
No.
You don't need the one from QTcpSocket. QTcpSocket::disconnectFromHost() should handle the unsent data. Also you should remove "socket->close()", because it's just an equivalent of disconnectFromHost().
PS. Why do you create both text stream and the socket on the heap, if you need them only in one function?
Bookmarks