title: Qt QUdpSocket: readyRead() signal and corresponding slot not working as supposed
body: <p>I have problems to find why my short <code>QUdpSocket</code> example is not working. I plan to use only one UDP socket to read and write to an embedded device at 192.168.2.66 on port 2007. The device will reply always on port 2007 to the sender. I tested the device with an UDP terminal software and works as I said. So, I designed a simple class to embed the functions needed to manage the device:</p>
  
  <pre><code>class QUdp : public QObject
  {
      // Q_OBJECT
  public:
      explicit QUdp(QObject *parent = 0, const char *szHost = 0, uint16_t wPort = 0);
      ~QUdp();
      bool Open();
      int64_t Write(QByteArray &amp;data);
      int64_t Write(QString strData);
  private:
      QString m_strHost;
      uint16_t m_wPort;
      QUdpSocket *OUdp;
  private slots:
      void received();
  };
  </code></pre>
  
  <p>I suppose that the problem is in the Open method:</p>
  
  <pre><code>bool QUdp::Open()
  {
      QHostAddress OHost;
      connect(OUdp, &amp;QUdpSocket::readyRead, this, &amp;QUdp::received);
      bool zRet = OUdp-&gt;bind(QHostAddress::AnyIPv4, m_wPort, QUdpSocket::ShareAddress);
      OHost.setAddress(m_strHost);
      OUdp-&gt;connectToHost(OHost, m_wPort, QIODevice::ReadWrite);
      return(zRet);
  }
  //------------------------------------------------------------------------
  </code></pre>
  
  <p>I used the Qt 5 syntax for the connect(), <code>m_strHost</code> value is "192.168.2.66" and <code>m_wPort</code> is 2007</p>
  
  <p>my Write method is very simple (the part inside #if 0 was added to see if the socket received any data)</p>
  
  <pre><code>int64_t QUdp::Write(QString strData)
  {
      QByteArray data(strData.toStdString().c_str(), strData.length());
      int64_t iCount = OUdp-&gt;write(data);
  #if 0
      bool zRecved = OUdp-&gt;waitForReadyRead(3000);
      int64_t iRecvCount = OUdp-&gt;bytesAvailable();
  #endif
      return(iCount);
  }
  //------------------------------------------------------------------------
  </code></pre>
  
  <p>and this is my test received() method... I wrote it just to see if the signal-slot works or not:</p>
  
  <pre><code>void QUdp::received()
  {
      int64_t iRecvCount = OUdp-&gt;bytesAvailable();
  }
  //------------------------------------------------------------------------
  </code></pre>
  
  <p>I don't understand what is wrong.. I found some posts saying that is not possible read and write using only one UDP socket in Qt (Qt uses BSD sockets so it should be possible) but my example looks as the proposed solutions so I really don't understand what is not working. </p>