3 #include <boost/beast.hpp> 4 #include "../general_store.hpp" 9 class TcpListener :
public std::enable_shared_from_this<TcpListener> {
10 boost::beast::net::ip::tcp::acceptor acceptor_;
11 boost::beast::net::ip::tcp::socket socket_;
12 std::reference_wrapper<GeneralStore> gstore;
15 TcpListener(boost::beast::net::io_context& ioc,
const boost::beast::net::ip::tcp::endpoint& endpoint,
GeneralStore& gstore)
16 : acceptor_(ioc), socket_(ioc), gstore(gstore) {
17 boost::beast::error_code ec;
20 acceptor_.open(endpoint.protocol(), ec);
27 acceptor_.set_option(boost::beast::net::socket_base::reuse_address(
true), ec);
29 fail(ec,
"set_option");
34 acceptor_.bind(endpoint, ec);
41 acceptor_.listen(boost::beast::net::socket_base::max_listen_connections, ec);
50 if (!acceptor_.is_open())
63 std::make_shared<Session>(std::move(socket_), gstore)->
run();
void run()
Definition: tcp_listener.hpp:49
Definition: tcp_listener.hpp:9
TcpListener(boost::beast::net::io_context &ioc, const boost::beast::net::ip::tcp::endpoint &endpoint, GeneralStore &gstore)
Definition: tcp_listener.hpp:15
void do_accept()
Definition: tcp_listener.hpp:55
void fail(boost::beast::error_code ec, const char *what)
Definition: beast_internals.hpp:6
void on_accept(boost::beast::error_code ec)
Definition: tcp_listener.hpp:57
Definition: general_store.hpp:5