std::shared_ptr
[dcpomatic.git] / src / lib / server.cc
index 1fb3d7d471863a2c3e81ec3c65480c131d2ada47..acb8d08d8e800cbbf429ac1ff924d2ef6c8f75ca 100644 (file)
 
 #include "i18n.h"
 
-using boost::shared_ptr;
+using std::shared_ptr;
 
-Server::Server (int port)
+Server::Server (int port, int timeout)
        : _terminate (false)
        , _acceptor (_io_service, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port))
+       , _timeout (timeout)
 {
 
 }
@@ -40,7 +41,7 @@ Server::~Server ()
        }
 
        _acceptor.close ();
-       _io_service.stop ();
+       stop ();
 }
 
 void
@@ -60,7 +61,7 @@ Server::start_accept ()
                }
        }
 
-       shared_ptr<Socket> socket (new Socket);
+       shared_ptr<Socket> socket (new Socket(_timeout));
        _acceptor.async_accept (socket->socket (), boost::bind (&Server::handle_accept, this, socket, boost::asio::placeholders::error));
 }
 
@@ -74,3 +75,9 @@ Server::handle_accept (shared_ptr<Socket> socket, boost::system::error_code cons
        handle (socket);
        start_accept ();
 }
+
+void
+Server::stop ()
+{
+       _io_service.stop ();
+}