Qtcp client not working
-
hi all.one help
server send a 1000kb of data to client...
in client
i include the code:
QBytearray ba=socket.readall();
//then i opened a file to write a ba to the file ..
only 2kb of content only writing -
@karti-gesar
probably the most common misassumption in in socket programming:
Just because you send 10kb of data from the server doesn't mean that the client receives the 10kb at once. But the client will receive it in chunks.So you need to read from the socket consecutively until all data is received. Whenever the readyRead() signal is triggered, or you use the blocking approach using waitForReadyRead()
-
k i will try
-
try
while(socket.waitForReadyRead(100))
{
}
/*After the last chunk will been received by client, QAbstractSocket::waitForReadyRead() will return false */QBytearray ba=socket.readall();
-
@Delphi251189 inside while statement what to add ?
-
completed by using while(readyread())..thank for all