title: how could a server send data to a client behind nat by udp in qt?
body: <p>The server has a public IP, the client is behind a nat.</p>
  
  <p>How could the client communicate with server by udp in qt?</p>
  
  <p>The client will send some data to server first, then how could server reply to client?</p>
  
  <p>The current code is this:</p>
  
  <p>server:</p>
  
  <pre><code>self.udpSocketGet = QtNetwork.QUdpSocket()
  self.udpSocketGet.bind(QtNetwork.QHostAddress.LocalHost, serverPort)
  self.udpSocketGet.readyRead.connect(self.receive)
  
  def receive(self):
      while self.udpSocketGet.hasPendingDatagrams():
          size = self.udpSocketGet.pendingDatagramSize()
          if size &gt; 0:
              data, senderAddr, senderPort = self.udpSocketGet.readDatagram(size)
  </code></pre>
  
  <p>client:</p>
  
  <pre><code>def sentToServer(self,data):
      udpSocketSend = QtNetwork.QUdpSocket()
      udpSocketSend.writeDatagram(data.encode('utf-8'), serverAddress, serverPort)
  </code></pre>