diff options
author | Othmar Gsenger <otti@anytun.org> | 2008-10-19 20:23:49 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@anytun.org> | 2008-10-19 20:23:49 +0000 |
commit | 3c66fe726ae8044b2d3ce90115217a6240473598 (patch) | |
tree | d0d2f3575d23c8262c07f35343177fd4706d95c8 /src/syncServer.cpp | |
parent | move to asio socket libary for sync (diff) |
now with files
Diffstat (limited to 'src/syncServer.cpp')
-rw-r--r-- | src/syncServer.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
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(); + } +} |