Hello everyone,

could someone tell me the reason for the code below does not send the data? I think that the data is being buffered, rather than sent

Qt Code:
  1.  
  2. int type_msg = 6;
  3. data.append( (char*)&type_msg, sizeof(int) );
  4.  
  5. string video_server_address;
  6. in >> video_server_address;
  7.  
  8. int num_char_video_server_address = video_server_address.size();
  9. data.append( (char*)&num_char_video_server_address, sizeof(int) );
  10.  
  11. data.append( QString(video_server_address.c_str()) );
  12.  
  13. int num_bytes_write = clientSocket->write( data.data(), data.size() );
  14. clientSocket->flush();
  15.  
  16. while( clientSocket->bytesToWrite() > 0 ){
  17. num_bytes_write += clientSocket->write( data.data()+num_bytes_write, data.size()-num_bytes_write );
  18. clientSocket->flush();
  19. clientSocket->waitForBytesWritten();
  20. }
To copy to clipboard, switch view to plain text mode 

before this code a lot of data has been sent successfully the same way, but these last 17 bytes were not received by the client

clientSocket is a variable whose type is QTcpSocket.

Thanks