title: How to send and receive large data using Qt UDP socket?
body: <p>I want to use Qt UDP (not TCP) socket to transfer file.
  So I write code like this:</p>
  
  <p>Sender</p>
  
  <pre><code>QFile file1(QString::fromStdString(filedir));
  QByteArray bytes;
  file1.open(QIODevice::ReadOnly);
  QTextStream in(&amp;file1);
  while (!in.atEnd()) {
      bytes = in.read(8192).toAscii();
      udpSocket.writeDatagram(bytes, QHostAddress(ip), port.toInt());
  }
  </code></pre>
  
  <p>Receiver</p>
  
  <pre><code>udpSocket1.bind(ui-&gt;sendPort-&gt;text().toInt());
  connect(&amp;udpSocket1,SIGNAL(readyRead()),this,SLOT(listenfile()));
  
  void Widget::listenfile() {
      QFile file("received.txt");
      file.resize(0);
      file.open(QIODevice::Append);
      QTextStream out(&amp;file);
      do {
          QByteArray data;
          data.resize(udpSocket1.pendingDatagramSize());
          udpSocket1.readDatagram(data.data(),data.size());
          QString str=data.data();
          ui-&gt;textBrowser1-&gt;append(str);
          out &lt;&lt; data;
      } while (udpSocket1.hasPendingDatagrams());
  }
  </code></pre>
  
  <p>When I send small file, there is no problem.
  However, if i want to send large file (> 8192 bytes), the receiver can only get the top 8KB data even tested on localhost.
  If I decrease the size number in sender, such as 1024. The receiver still only gets the top 8KB data.
  If I increase the size number in sender to X bytes (X > 8192). The receiver will get the top X Bytes data.</p>
  
  <p>It seems like the minimum size of Qt UDP packet to transfer is 8192 bytes. The receiver always gets the first packet, but can not receive others.</p>
  
  <p>I have little experience in Qt and network programming, so I don't know whether my conjecture is right or not. Can you tell me how to change these codes to support receiving packets after the first packet so I can transfer large data?</p>