summaryrefslogtreecommitdiff
path: root/src/syncServer.h
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-03-22 23:57:35 +0000
committerChristian Pointner <equinox@anytun.org>2009-03-22 23:57:35 +0000
commit623e15d35dffbda9f30d0d4aa7e42439723df31e (patch)
treee3487d30ec5c67a1d6cdf669fa51af5a903e127f /src/syncServer.h
parentadded gResolver to anytun-config (diff)
added gResolver to SyncServer
some cleanup
Diffstat (limited to 'src/syncServer.h')
-rw-r--r--src/syncServer.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/syncServer.h b/src/syncServer.h
index fa5fe1f..138f46e 100644
--- a/src/syncServer.h
+++ b/src/syncServer.h
@@ -44,18 +44,28 @@
#include <list>
#include "syncTcpConnection.h"
+typedef boost::function<void (SyncTcpConnection *)> ConnectCallback;
+
class SyncServer
{
public:
- SyncServer(boost::asio::io_service& io_service, SyncTcpConnection::proto::endpoint tcp_endpoint );
- boost::function<void(SyncTcpConnection *)> onConnect;
+ SyncServer(std::string localaddr, std::string port, ConnectCallback onConnect);
+ void onResolve(const SyncTcpConnection::proto::endpoint& e);
+ void onResolvError(const std::runtime_error& e);
+
+ void run();
+ void send(std::string message);
+
std::list<SyncTcpConnection::pointer> conns_;
- void send(std::string message);
+
private:
void start_accept();
- void handle_accept(SyncTcpConnection::pointer new_connection,
- const boost::system::error_code& error);
- Mutex mutex_; //Mutex for list conns_
+ void handle_accept(SyncTcpConnection::pointer new_connection, const boost::system::error_code& error);
+
+ Mutex mutex_; //Mutex for list conns_
+ boost::asio::io_service io_service_;
SyncTcpConnection::proto::acceptor acceptor_;
+ ConnectCallback onConnect_;
+ Semaphore ready_sem_;
};
#endif