summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordknn <yoann.blein@free.fr>2012-07-15 18:26:38 (GMT)
committerdknn <yoann.blein@free.fr>2012-09-22 09:01:49 (GMT)
commit05ef8661b2f42cc5b889f3900b459d8a49a24db3 (patch)
tree7069699ead4ba74eb91aa37090c80ab25c6db352 /Swiften/Network
parentc9ba8e43fc23fccd47531ecea73224b3b9b552c3 (diff)
downloadswift-contrib-05ef8661b2f42cc5b889f3900b459d8a49a24db3.zip
swift-contrib-05ef8661b2f42cc5b889f3900b459d8a49a24db3.tar.bz2
Handle all kind of ip in udp and screen sharing
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostUDPSocket.cpp20
-rw-r--r--Swiften/Network/BoostUDPSocket.h4
-rw-r--r--Swiften/Network/UDPSocket.h4
3 files changed, 18 insertions, 10 deletions
diff --git a/Swiften/Network/BoostUDPSocket.cpp b/Swiften/Network/BoostUDPSocket.cpp
index cedaad4..4405091 100644
--- a/Swiften/Network/BoostUDPSocket.cpp
+++ b/Swiften/Network/BoostUDPSocket.cpp
@@ -52,24 +52,28 @@ BoostUDPSocket::~BoostUDPSocket()
{
}
-void BoostUDPSocket::bind(int port)
+void BoostUDPSocket::bind(const HostAddressPort& addr)
{
if (!socket_.is_open())
- socket_.open(boost::asio::ip::udp::v4());
- socket_.bind(boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port));
+ socket_.open(addr.toEndpoint().protocol());
+ socket_.bind(addr.toEndpoint());
+}
+
+void BoostUDPSocket::bindOnAvailablePort(const HostAddress &addr)
+{
+ bind(HostAddressPort(addr, 0));
}
void BoostUDPSocket::listen()
{
- if (!socket_.is_open())
- socket_.open(boost::asio::ip::udp::v4());
- doRead();
+ if (socket_.is_open())
+ doRead();
}
void BoostUDPSocket::connect(const HostAddressPort &address)
{
- if (!socket_.is_open())
- socket_.open(boost::asio::ip::udp::v4());
+// if (!socket_.is_open())
+// socket_.open(boost::asio::ip::udp::v4());
socket_.connect(address.toEndpoint()); // TODO: handle errors
eventLoop->postEvent(boost::bind(boost::ref(onConnected)), shared_from_this());
}
diff --git a/Swiften/Network/BoostUDPSocket.h b/Swiften/Network/BoostUDPSocket.h
index c7de5b7..bb5014e 100644
--- a/Swiften/Network/BoostUDPSocket.h
+++ b/Swiften/Network/BoostUDPSocket.h
@@ -24,6 +24,7 @@ namespace boost {
namespace Swift {
class EventLoop;
+ class HostAddress;
class HostAddressPort;
class BoostUDPSocket : public UDPSocket, public EventOwner, public boost::enable_shared_from_this<BoostUDPSocket> {
@@ -36,7 +37,8 @@ namespace Swift {
return ref(new BoostUDPSocket(ioService, eventLoop));
}
- virtual void bind(int port);
+ virtual void bind(const HostAddressPort& addr);
+ virtual void bindOnAvailablePort(const HostAddress& addr);
virtual void listen();
virtual void connect(const HostAddressPort& address);
virtual void connectToFirstIncoming();
diff --git a/Swiften/Network/UDPSocket.h b/Swiften/Network/UDPSocket.h
index 4ba9962..3a239f8 100644
--- a/Swiften/Network/UDPSocket.h
+++ b/Swiften/Network/UDPSocket.h
@@ -11,6 +11,7 @@
namespace Swift {
class EventLoop;
+ class HostAddress;
class HostAddressPort;
class UDPSocket {
@@ -19,7 +20,8 @@ namespace Swift {
virtual ~UDPSocket() {}
- virtual void bind(int port) = 0;
+ virtual void bind(const HostAddressPort& addr) = 0;
+ virtual void bindOnAvailablePort(const HostAddress& addr) = 0;
virtual void listen() = 0;
virtual void connect(const HostAddressPort& address) = 0;
virtual void connectToFirstIncoming() = 0;