Browse Source

give this a try on Windoze

pull/1/head
Volker Birk 2 years ago
parent
commit
14b6eb5b32
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      webserver.cc

+ 11
- 4
webserver.cc View File

@ -232,15 +232,22 @@ the_end:
void Webserver::runner(Webserver *me)
{
#ifdef WIN32
typedef
boost::asio::detail::socket_option::boolean<BOOST_ASIO_OS_DEF(SOL_SOCKET),
SO_EXCLUSIVEADDRUSE> excluse_address;
me->_acceptor.set_option(excluse_address(true));
typedef boost::asio::detail::socket_option::boolean<
BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_EXCLUSIVEADDRUSE)>
exclusive_addr_use_t;
exclusive_addr_use_t exclusive_addr_use(true);
#endif
boost::asio::socket_base::keep_alive keep_alive(true);
boost::asio::socket_base::keep_alive reuse_address(false);
while (me->_running)
{
tcp::socket* socket = new tcp::socket{me->_ioc};
#ifdef WIN32
me->_acceptor.set_option(exclusive_addr_use);
#endif
me->_acceptor.set_option(keep_alive);
me->_acceptor.set_option(reuse_address);
me->_acceptor.accept(*socket);
std::function< void() > tf = [=]()


Loading…
Cancel
Save