Hi everyone. this is my problem i developed a chat program (voice and text) using framework Qt. i can send and receive text perfectly and also i can send voice over network and receiving it. the problem is i can't do both thing at the same time. can you please help me to send text and voice over network using Qt Framework.
for Sending text :
client side:
Qt Code:
  1. QString messageAEnvoyer ;
  2. messageAEnvoyer ="Christina"
  3. out << (quint16) 0;
  4. out << messageAEnvoyer;
  5. out.device()->seek(0);
  6. out << (quint16) (paquet.size() - sizeof(quint16));
  7. socket->write(paquet);
To copy to clipboard, switch view to plain text mode 
for receiving text :
Qt Code:
  1. MessageText *messageArive;
  2. QDataStream in(socket);
  3. forever{
  4. if (tailleMessage == 0)
  5. {
  6. if (socket->bytesAvailable() < sizeof(tailleMessage))
  7. {
  8. break;
  9. }
  10. in >> tailleMessage;
  11. }
  12. if (socket->bytesAvailable() < tailleMessage){
  13. break;
  14. }
  15. QString messageRecu;
  16. in >> messageRecu;
  17. //do something wih the msg
To copy to clipboard, switch view to plain text mode 

for voice client side i use
Qt Code:
  1. void Widget::on_pushButton_clicked()
  2. {
  3. socket = new QTcpSocket(this);
  4. socket->connectToHost(ui->lineEdit->text(),quint16(5002)); connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(error()));
  5.  
  6. QAudioFormat format;
  7. format.setSampleRate(44100);
  8. format.setChannelCount(2);
  9. format.setSampleSize(16);
  10. format.setCodec("audio/pcm");
  11. format.setByteOrder(QAudioFormat::LittleEndian);
  12. format.setSampleType(QAudioFormat::SignedInt);
  13.  
  14. //If format isn't supported find the nearest supported
  15. QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
  16. if (!info.isFormatSupported(format))
  17. format = info.nearestFormat(format);
  18. ui->label_2->setText(info.deviceName()); // the supported Input device
  19.  
  20.  
  21. QAudioFormat format2;
  22. format2.setSampleRate(44100);
  23. format2.setChannelCount(2);
  24. format2.setSampleSize(16);
  25. format2.setCodec("audio/pcm");
  26. format2.setByteOrder(QAudioFormat::LittleEndian);
  27. format2.setSampleType(QAudioFormat::SignedInt);
  28.  
  29. QAudioDeviceInfo info2(QAudioDeviceInfo::defaultOutputDevice());
  30. if (!info2.isFormatSupported(format2))
  31. format2 = info2.nearestFormat(format2);
  32. ui->label->setText(info2.deviceName()); // the supported output device
  33.  
  34. input = new QAudioInput(format);
  35. input->setBufferSize(16384); // set buffere size to solve sound distribution on windows but not solve this problem when use it in android
  36.  
  37. output = new QAudioOutput(format2);
  38. output->setBufferSize(16384);
  39.  
  40. device = output->start();
  41.  
  42. input->start(socket);
  43.  
  44. connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
  45. }
  46.  
  47. void Widget::error()
  48. {
  49. ui->label->setText(socket->errorString());
  50. }
  51.  
  52.  
  53. }
To copy to clipboard, switch view to plain text mode 
for receiving voice :
Qt Code:
  1. while (socket->bytesAvailable() > 0){
  2. QByteArray arr = socket->readAll();
  3. device->write(arr.data(),arr.size());}
To copy to clipboard, switch view to plain text mode 

please help me to do both at the sametime thank you so much in advance