MCPcopy Create free account
hub / github.com/KDAB/GammaRay / externalAddress

Method externalAddress

core/remote/tcpserverdevice.cpp:77–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77QUrl 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
112void TcpServerDevice::broadcast(const QByteArray &data)
113{

Callers

nothing calls this directly

Calls 2

serverAddressMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected