title: UDP voice chat on Qt
body: <p>First, I'm trying to send audio data from one process to other via the UDP protocol on localhost.</p>
  
  <p>First, the program reads voice from the microphone and sends it via UDP socket:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QIODevice&gt;
  #include &lt;QtMultimediaKit/QAudioOutput&gt;
  #include &lt;QtMultimediaKit/QAudioInput&gt;
  #include &lt;QtMultimediaKit/QAudioFormat&gt;
  #include &lt;QUdpSocket&gt;
  
  int main(int argc, char** argv){
      QApplication app(argc, argv);
      QAudioFormat format;
      format.setSampleRate(128000);
      format.setChannelCount(1);
      format.setSampleSize(16);
      format.setCodec("audio/pcm");
      format.setByteOrder(QAudioFormat::LittleEndian);
      format.setSampleType(QAudioFormat::UnSignedInt);
      QAudioInput* input = new QAudioInput(format);
      QUdpSocket* socket = new QUdpSocket();
      socket-&gt;connectToHost("127.0.0.1", 1002);
      input-&gt;start(socket);
      return app.exec();
  }
  </code></pre>
  
  <p>I check data sending in by Wireshark, and I think data is sent. So many UDP packages per second on the 1002 port.</p>
  
  <p>The second program should read UDP packages and play it in the output device:</p>
  
  <pre><code>#include "UDPPlayer.h"
  #include &lt;QDebug&gt;
  
  UDPPlayer::UDPPlayer(){
      socket = new QUdpSocket();
      socket-&gt;bind(1002);
      QAudioFormat format;
      format.setSampleRate(128000);
      format.setChannelCount(1);
      format.setSampleSize(16);
      format.setCodec("audio/pcm");
      format.setByteOrder(QAudioFormat::LittleEndian);
      format.setSampleType(QAudioFormat::UnSignedInt);
      output = new QAudioOutput(format);
      connect(socket, SIGNAL(readyRead()), this, SLOT(playData()));
  }
  
  void UDPPlayer::playData(){
      qDebug() &lt;&lt; "data";
      output-&gt;start(socket);
  }
  </code></pre>
  
  <p>The problem is the following: <code>playData()</code> is never called ("data" is never printed). Does it mean that the socket is never <code>readyRead</code>? But I see these packages by Wireshark. What am I doing wrong?</p>