summaryrefslogtreecommitdiff
path: root/src/tcpserver.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tcpserver.h')
-rw-r--r--src/tcpserver.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tcpserver.h b/src/tcpserver.h
new file mode 100644
index 0000000..47c5056
--- /dev/null
+++ b/src/tcpserver.h
@@ -0,0 +1,27 @@
+#ifndef TCPSERVER_H
+#define TCPSERVER_H
+
+#include <boost/asio.hpp>
+#include <boost/function.hpp>
+
+#include "connection.h"
+
+class TCPServer {
+ private:
+ boost::asio::ip::tcp::acceptor acceptor_;
+
+ boost::function<void (Connection::p)> connect_callback;
+
+ //! Listen for incoming connection.
+ void listen();
+
+ //! Handle new connection.
+ void handle_connection(Connection::p connection, const boost::system::error_code& error);
+
+ public:
+ TCPServer(boost::asio::io_service& io_service);
+
+ void get_connection(boost::function<void (Connection::p)> f);
+};
+
+#endif