0

i write this code but unfortunately i cant receive whole data and only receive 1.4 k byte but i should receive 64 K byte. what should I do please help me.

     QByteArray ba2;
     ba2.resize(2);
     ba2[0] = 0x00;
     ba2[1] = 0xc0;
     Client ob;
     ob.connectToHost();
     ob.writeData(ba2);



    QByteArray Client:: readback(QByteArray data)
      {
    qDebug() << socket->readAll();

     return data;
      }

       void Client::connectToHost()
     {
      socket->connectToHost("192.168.100.17", 1134);

      }


     void Client::close()
    {
  socket->close();

       }

   Client::Client(QObject *parent) : QObject(parent)
    {
    socket = new QTcpSocket();
   connect(socket, SIGNAL(readyRead()), this, SLOT(readback(QByteArray data)));

     }
mehdi
  • 11
  • 1
  • 2
    How do you know you don't receive everything? And what do you send? How do you send it? And can you please try to create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve) and show us? Of both the receiver and sender? – Some programmer dude Jul 12 '17 at 14:02
  • 1
    `ReadAll()` will return currently available data in it's buffer. You should create some kind of protocol ( message framing ) to distinguish how many bytes to read from data or stick to one packet length. Either way `ReadAll()` is not the best thing to do when dealing with networking ... additionaly read [this answer](https://stackoverflow.com/questions/28955961/qt-socket-does-no-read-all-data) – mrogal.ski Jul 12 '17 at 14:08

0 Answers0