From db5ad2e09a6b38e841463dbe7eb076492b62c948 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 18 Aug 2009 15:58:17 +0200 Subject: Mad funktioniert jetzt unter Windows --- src/Net/Listener.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/Net/Listener.cpp') diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp index 89ea399..6187a1e 100644 --- a/src/Net/Listener.cpp +++ b/src/Net/Listener.cpp @@ -26,6 +26,20 @@ namespace Mad { namespace Net { +void Listener::accept() { + boost::shared_ptr con(new Connection(application)); + + con->context.set_options(boost::asio::ssl::context::default_workarounds + | boost::asio::ssl::context::no_sslv2 + | boost::asio::ssl::context::single_dh_use); + con->context.use_certificate_chain_file(x905CertFile); + con->context.use_private_key_file(x905KeyFile, boost::asio::ssl::context::pem); + + con->_initSocket(); + + acceptor.async_accept(con->socket->lowest_layer(), boost::bind(&Listener::handleAccept, this, boost::asio::placeholders::error, con)); +} + void Listener::handleAccept(const boost::system::error_code &error, boost::shared_ptr con) { if(error) return; @@ -42,11 +56,10 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share connections.insert(std::make_pair(con, std::make_pair(con1, con2))); - con->socket.async_handshake(boost::asio::ssl::stream_base::server, boost::bind(&Connection::handleHandshake, con, boost::asio::placeholders::error)); + con->socket->async_handshake(boost::asio::ssl::stream_base::server, boost::bind(&Connection::handleHandshake, con, boost::asio::placeholders::error)); } - con.reset(new Connection(application, sslContext)); - acceptor.async_accept(con->socket.lowest_layer(), boost::bind(&Listener::handleAccept, this, boost::asio::placeholders::error, con)); + accept(); } void Listener::handleConnect(boost::shared_ptr con) { @@ -76,19 +89,8 @@ void Listener::handleDisconnect(boost::shared_ptr con) { Listener::Listener(Core::Application *application0, const std::string &x905CertFile0, const std::string &x905KeyFile0, const boost::asio::ip::tcp::endpoint &address0) throw(Core::Exception) : application(application0), x905CertFile(x905CertFile0), x905KeyFile(x905KeyFile0), address(address0), -acceptor(application->getIOService(), address), sslContext(application->getIOService(), boost::asio::ssl::context::sslv23), -signal(application) -{ - sslContext.set_options(boost::asio::ssl::context::default_workarounds - | boost::asio::ssl::context::no_sslv2 - | boost::asio::ssl::context::single_dh_use); - sslContext.use_certificate_chain_file(x905CertFile0); - sslContext.use_private_key_file(x905KeyFile0, boost::asio::ssl::context::pem); - - - - boost::shared_ptr con(new Connection(application, sslContext)); - acceptor.async_accept(con->socket.lowest_layer(), boost::bind(&Listener::handleAccept, this, boost::asio::placeholders::error, con)); +acceptor(application->getIOService(), address), signal(application) { + accept(); } Listener::~Listener() { -- cgit v1.2.3