title: How to write a C++ socket programming based UDP with QT?
body: <p>I'm trying to write a program that reads broadcasted UDP datagrams in linux.I'm a beginner in socket programming .<br>
  My code is :</p>
  
  <pre><code>#include &lt;QUdpSocket&gt;
  #include &lt;iostream&gt;
  
  
  int main ()
  {
      QUdpSocket *udpSocket ;
      udpSocket= new QUdpSocket(0);
      udpSocket-&gt;bind(QHostAddress::LocalHost, 3838);
  
  
      udpSocket-&gt;connect(udpSocket, SIGNAL(readyRead()),
               this, SLOT(readPendingDatagrams()));
  
      while (1)
      {
          if (udpSocket-&gt;hasPendingDatagrams())
          {
               QByteArray datagram;
               datagram.resize(udpSocket-&gt;pendingDatagramSize());
               QHostAddress sender;
               quint16 senderPort;
  
               udpSocket-&gt;readDatagram(datagram.data(), datagram.size(),
                                       &amp;sender, &amp;senderPort);
          }
      }
  }
  </code></pre>
  
  <p>but it returns error in <code>this</code>.</p>
  
  <blockquote>
    <p>main.cpp:13:18: error: invalid use of ‘this’ in non-member function</p>
  </blockquote>
  
  <p>what should I do ?</p>