title: QUdpSocket writeDatagram() returns error 7 (Unable to send a message)
body: <p>I am working on Qt app, which is basically <code>QTcpServer</code> containing several <code>QTcpSocket</code> and <code>QUdpSocket</code> objects. Now, once app is started, the <code>QTcpServer</code> is started and for now, for simplicity <code>QUdpSocket</code> is started and I am sending broadcast data to <code>LAN</code> every <strong>5 seconds</strong> using this <code>QUdpSocket</code>, which works fine:</p>
  
  <pre><code>void UeMainWindow::ueSlotNetworkInformationBroadcastTimerTimeout()
  {
      QList&lt;QVariant&gt; parameters;
      QByteArray datagram;
  
      parameters.append(this-&gt;ueTcpServer()-&gt;ueServerIPv4().toString());
      parameters.append(QString::number(this-&gt;ueTcpServer()-&gt;ueServerPort()));
  
      datagram=UePOSCommProtocol::ueEncodeCommand(UePosCommProtocolArch::UeCommand::CMD_GET_NETWORK_SETTINGS,
                                                  parameters);
  
      if(this-&gt;ueNetworkInformationSocket()-&gt;writeDatagram(datagram.data(),
                                                           datagram.size(),
                                                           QHostAddress::Broadcast,
                                                           20000)&gt;0)
      {
          this-&gt;ueSlotAddEventInfoLog(UeLogEntryType::INFO,
                                      tr("Newtwork information data")
                                      .append(" ")
                                      .append(datagram.toHex())
                                      .append(" ")
                                      .append(tr("sent via broadcast")));
      }
      else
      {
          this-&gt;ueSlotAddEventInfoLog(UeLogEntryType::ERROR,
                                      tr("Error sending Newtwork information data")
                                      .append(" ")
                                      .append(datagram.toHex())
                                      .append(" ")
                                      .append(tr("via broadcast"))
                                      .append(" ")
                                      .append(tr("with error"))
                                      .append(" ")
                                      .append(QString::number(this-&gt;ueNetworkInformationSocket()-&gt;error()))
                                      .append(" ")
                                      .append("(")
                                      .append(this-&gt;ueNetworkInformationSocket()-&gt;errorString())
                                      .append(")"));
      }   // if
  }   // ueSlotNetworkInformationBroadcastTimerTimeout
  </code></pre>
  
  <p>Now, I am trying to simulate network disconnection with turning off Wi-Fi while app is running. The app detects network change via <a href="http://doc.qt.io/qt-5/qnetworkconfigurationmanager.html#configurationChanged" rel="nofollow noreferrer">QNetworkConfigurationManager::onfigurationChanged(const QNetworkConfiguration &amp;config</a> and restarts server binding it to <code>localhost</code>:</p>
  
  <pre><code>void UeMainWindow::ueSlotNetworkOnlineStateChanged(bool isOnline)
  {
      this-&gt;ueSlotAddEventInfoLog(isOnline?UeLogEntryType::INFO:UeLogEntryType::ERROR,
                                  tr("Network online state changed").append(" ")
                                                                    .append(isOnline?tr(" ONLINE "):tr(" OFFLINE ")));
      if(!isOnline)
      {
          this-&gt;ueTcpServer()-&gt;ueRestart(QHostAddress::LocalHost,
                                         20000);
      }   // if
  }   // ueSlotNetworkOnlineStateChanged
  </code></pre>
  
  <p>Once this is done, I again try to send data via <code>QUdpSocket</code> with first code chunk, but I get <a href="http://doc.qt.io/qt-5/qabstractsocket.html#SocketError-enum" rel="nofollow noreferrer">error 7</a>:
  <a href="https://i.stack.imgur.com/Mgwul.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mgwul.png" alt="QUdpSocket::writeDatagram() error"></a>
  Why? Is it even possible to send <code>Broadcast</code> via <code>loopback</code>/<code>localhost</code>?</p>