Qtcp client not working
-
wrote on 30 Nov 2016, 11:30 last edited by
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 -
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()
-
wrote on 30 Nov 2016, 11:52 last edited by
k i will try
-
wrote on 1 Dec 2016, 07:34 last edited by Delphi251189 12 Jan 2016, 07:35
try
while(socket.waitForReadyRead(100))
{
}
/*After the last chunk will been received by client, QAbstractSocket::waitForReadyRead() will return false */QBytearray ba=socket.readall();
-
try
while(socket.waitForReadyRead(100))
{
}
/*After the last chunk will been received by client, QAbstractSocket::waitForReadyRead() will return false */QBytearray ba=socket.readall();
wrote on 1 Dec 2016, 08:42 last edited by@Delphi251189 inside while statement what to add ?
-
wrote on 1 Dec 2016, 13:40 last edited by
completed by using while(readyread())..thank for all
1/6