diff options
author | dknn <yoann.blein@free.fr> | 2012-07-16 12:00:56 (GMT) |
---|---|---|
committer | dknn <yoann.blein@free.fr> | 2012-09-22 09:01:49 (GMT) |
commit | 292967c02ffc2ff0b53df526af2965a03916290c (patch) | |
tree | 6712ee7c70d4a68af1cd7e46f6929f4bfce2f27d /Swiften/ScreenSharing/ScreenSharing.cpp | |
parent | 05ef8661b2f42cc5b889f3900b459d8a49a24db3 (diff) | |
download | swift-contrib-292967c02ffc2ff0b53df526af2965a03916290c.zip swift-contrib-292967c02ffc2ff0b53df526af2965a03916290c.tar.bz2 |
Better handling of udp bind errors
Diffstat (limited to 'Swiften/ScreenSharing/ScreenSharing.cpp')
-rw-r--r-- | Swiften/ScreenSharing/ScreenSharing.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/Swiften/ScreenSharing/ScreenSharing.cpp b/Swiften/ScreenSharing/ScreenSharing.cpp index c6c78e0..0a477c2 100644 --- a/Swiften/ScreenSharing/ScreenSharing.cpp +++ b/Swiften/ScreenSharing/ScreenSharing.cpp @@ -50,10 +50,11 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl PlatformNetworkEnvironment env; std::vector<NetworkInterface> interfaces = env.getNetworkInterfaces(); + serverSocket = udpSocketFactory->createUDPSocket(); + // Find the first ip which is not loopback - foreach (const NetworkInterface& interface, interfaces) { + /*foreach (const NetworkInterface& interface, interfaces) { if (!interface.isLoopback() && !interface.getAddresses().empty()) { // exclude loopback - serverSocket = udpSocketFactory->createUDPSocket(); serverSocket->bindOnAvailablePort(interface.getAddresses().front()); candidate.hostAddressPort = serverSocket->getLocalAddress(); @@ -62,19 +63,34 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl return true; } + }*/ + + foreach (const NetworkInterface& interface, interfaces) { + if (!interface.isLoopback()) { // exclude loopback + foreach (const HostAddress& addr, interface.getAddresses()) { + int port = serverSocket->bindOnAvailablePort(addr); + if (!port) + continue; + + candidate.hostAddressPort = serverSocket->getLocalAddress(); + candidate.type = JingleRawUDPTransportPayload::Candidate::Host; + transport->addCandidate(candidate); + + return true; + } + } } // else loopback for self sharing - if (!interfaces.empty() && !interfaces.front().getAddresses().empty()) { - serverSocket = udpSocketFactory->createUDPSocket(); - serverSocket->bindOnAvailablePort(interfaces.front().getAddresses().front()); - - candidate.hostAddressPort = serverSocket->getLocalAddress(); - candidate.type = JingleRawUDPTransportPayload::Candidate::Host; - transport->addCandidate(candidate); - - return true; - } + /*if (!interfaces.empty() && !interfaces.front().getAddresses().empty()) { + int port = serverSocket->bindOnAvailablePort(interfaces.front().getAddresses().front()); + if (port) { + candidate.hostAddressPort = serverSocket->getLocalAddress(); + candidate.type = JingleRawUDPTransportPayload::Candidate::Host; + transport->addCandidate(candidate); + return true; + } + }*/ return false; } |