From 3c66fe726ae8044b2d3ce90115217a6240473598 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Sun, 19 Oct 2008 20:23:49 +0000 Subject: now with files --- src/syncServer.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/syncServer.cpp (limited to 'src/syncServer.cpp') diff --git a/src/syncServer.cpp b/src/syncServer.cpp new file mode 100644 index 0000000..fc0c4bc --- /dev/null +++ b/src/syncServer.cpp @@ -0,0 +1,30 @@ +#include "syncServer.h" + +//using asio::ip::tcp; + +SyncServer::SyncServer(asio::io_service& io_service, asio::ip::tcp::endpoint tcp_endpoint ) + : acceptor_(io_service, tcp_endpoint) +{ + start_accept(); +} + +void SyncServer::start_accept() +{ + SyncTcpConnection::pointer new_connection = + SyncTcpConnection::create(acceptor_.io_service()); + conns_.push_back(new_connection); + + acceptor_.async_accept(new_connection->socket(), + boost::bind(&SyncServer::handle_accept, this, new_connection, + asio::placeholders::error)); +} + +void SyncServer::handle_accept(SyncTcpConnection::pointer new_connection, + const asio::error_code& error) +{ + if (!error) + { + new_connection->start(); + start_accept(); + } +} -- cgit v1.2.3