summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-18 19:04:32 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-18 20:40:56 (GMT)
commit4457bc810a326de8d7895b3f2ff36ade5f1ae1a0 (patch)
tree1556c4b0190453897d4799d23b05e651b0bb8a32 /Swiften/Network
parent4052a822acd9da9dab6a8e2343c6170fb08dd8d6 (diff)
downloadswift-4457bc810a326de8d7895b3f2ff36ade5f1ae1a0.zip
swift-4457bc810a326de8d7895b3f2ff36ade5f1ae1a0.tar.bz2
Implement incoming linklocal connections.
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostConnection.cpp15
-rw-r--r--Swiften/Network/BoostConnection.h1
-rw-r--r--Swiften/Network/Connection.h8
3 files changed, 14 insertions, 10 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index d374221..b064c7a 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -51,18 +51,21 @@ void BoostConnection::listen() {
void BoostConnection::connect(const String& domain) {
DomainNameResolver resolver;
try {
- HostAddressPort addressPort = resolver.resolve(domain.getUTF8String());
- boost::asio::ip::tcp::endpoint endpoint(
- boost::asio::ip::address::from_string(addressPort.getAddress().toString()), addressPort.getPort());
- socket_.async_connect(
- endpoint,
- boost::bind(&BoostConnection::handleConnectFinished, shared_from_this(), boost::asio::placeholders::error));
+ connect(resolver.resolve(domain.getUTF8String()));
}
catch (const DomainNameResolveException& e) {
onDisconnected(DomainNameResolveError);
}
}
+void BoostConnection::connect(const HostAddressPort& addressPort) {
+ boost::asio::ip::tcp::endpoint endpoint(
+ boost::asio::ip::address::from_string(addressPort.getAddress().toString()), addressPort.getPort());
+ socket_.async_connect(
+ endpoint,
+ boost::bind(&BoostConnection::handleConnectFinished, shared_from_this(), boost::asio::placeholders::error));
+}
+
void BoostConnection::disconnect() {
//MainEventLoop::removeEventsFromOwner(shared_from_this());
socket_.close();
diff --git a/Swiften/Network/BoostConnection.h b/Swiften/Network/BoostConnection.h
index 76b6588..0ed6874 100644
--- a/Swiften/Network/BoostConnection.h
+++ b/Swiften/Network/BoostConnection.h
@@ -21,6 +21,7 @@ namespace Swift {
virtual void listen();
virtual void connect(const String& domain);
+ virtual void connect(const HostAddressPort& address);
virtual void disconnect();
virtual void write(const ByteArray& data);
diff --git a/Swiften/Network/Connection.h b/Swiften/Network/Connection.h
index c34c21d..25f9a16 100644
--- a/Swiften/Network/Connection.h
+++ b/Swiften/Network/Connection.h
@@ -1,5 +1,4 @@
-#ifndef SWIFTEN_CONNECTION_H
-#define SWIFTEN_CONNECTION_H
+#pragma once
#include <boost/signals.hpp>
@@ -7,6 +6,8 @@
#include "Swiften/Base/String.h"
namespace Swift {
+ class HostAddressPort;
+
class Connection {
public:
enum Error {
@@ -20,6 +21,7 @@ namespace Swift {
virtual ~Connection() {}
virtual void listen() = 0;
+ virtual void connect(const HostAddressPort& address) = 0;
virtual void connect(const String& domain) = 0;
virtual void disconnect() = 0;
virtual void write(const ByteArray& data) = 0;
@@ -30,5 +32,3 @@ namespace Swift {
boost::signal<void (const ByteArray&)> onDataRead;
};
}
-
-#endif