When i writing large data,for example 18MB data over QTcpSocket,the QTcpSocket terminated in Writing process...
first i used this code for writing:
Qt Code:
  1. client_socket->write(packet,packet.size());
  2. client_socket->waitForBytesWritten();
To copy to clipboard, switch view to plain text mode 
above code is not work correctly,and then i use this code for sending:
Qt Code:
  1. if (packet.size()>25344)
  2. {
  3. QDataStream data_stream(packet);
  4. data_stream.setVersion(QDataStream::Qt_5_3);
  5. while (!data_stream.atEnd())
  6. {
  7. int len=1024;
  8. char buffer[len];
  9. int size_read=data_stream.readRawData(buffer,len);
  10. if (size_read==-1)
  11. cout<<"ERROR!";
  12. client_socket->write(buffer,size_read);
  13. client_socket->waitForBytesWritten();
  14. }
  15. }
  16. else
  17. {
  18. client_socket->write(packet,packet.size());
  19. client_socket->waitForBytesWritten();
  20. }
To copy to clipboard, switch view to plain text mode 

and in another hand i using this code for reading data :
Qt Code:
  1. void server::readyRead()
  2. {
  3.  
  4. QTcpSocket *i_client=(QTcpSocket*) sender();
  5. quint16 packet_size=i_client->bytesAvailable();//Read Count Bytes waiting on line
  6. qDebug()<<"Packet Recived,Packet len: "<<QString::number(packet_size)<<"\n";
  7.  
  8. if (packet_size>0)
  9. {
  10.  
  11. QByteArray recive_bytes=i_client->read(packet_size);//Read Packet
  12. //...
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 
second way is better,but in both of tow methods ,QTcpSocket terminated after sending some bytes!
what's the problem!?