| 75 | } |
| 76 | |
| 77 | QUrl TcpServerDevice::externalAddress() const |
| 78 | { |
| 79 | const QHostAddress address(m_server->serverAddress()); |
| 80 | QString myHost; |
| 81 | |
| 82 | if (address.isLoopback()) { |
| 83 | myHost = address.toString(); |
| 84 | } else { |
| 85 | // scan Interfaces for available IPs, use requested address if we can find it. |
| 86 | myHost = bestAvailableIP(address); |
| 87 | } |
| 88 | |
| 89 | // if localhost is all we got, use that rather than nothing |
| 90 | if (myHost.isEmpty()) { |
| 91 | switch (m_server->serverAddress().protocol()) { |
| 92 | case QAbstractSocket::IPv4Protocol: |
| 93 | case QAbstractSocket::AnyIPProtocol: |
| 94 | myHost = QHostAddress(QHostAddress::LocalHost).toString(); |
| 95 | break; |
| 96 | case QAbstractSocket::IPv6Protocol: |
| 97 | myHost = QHostAddress(QHostAddress::LocalHostIPv6).toString(); |
| 98 | break; |
| 99 | case QAbstractSocket::UnknownNetworkLayerProtocol: |
| 100 | qWarning() << "TcpServerDevice::externalAddress - unknown TCP protocol"; |
| 101 | return m_address; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | QUrl url; |
| 106 | url.setScheme(QStringLiteral("tcp")); |
| 107 | url.setHost(myHost); |
| 108 | url.setPort(m_server->serverPort()); |
| 109 | return url; |
| 110 | } |
| 111 | |
| 112 | void TcpServerDevice::broadcast(const QByteArray &data) |
| 113 | { |
nothing calls this directly
no test coverage detected