从qtcpsocket

时间:2017-07-12 14:00:43

标签: c++ qt qtcpsocket

我写这段代码,但不幸的是我无法接收整个数据,只能接收1.4 k字节,但我应该收到64 K字节。我该怎么办请帮助我。

     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)));

     }

0 个答案:

没有答案