Browse Source

next try with native function

pull/1/head
Volker Birk 2 years ago
parent
commit
27c1153e78
1 changed files with 7 additions and 9 deletions
  1. +7
    -9
      webserver.cc

+ 7
- 9
webserver.cc View File

@ -231,23 +231,21 @@ the_end:
void Webserver::runner(Webserver *me)
{
#ifdef WIN32
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::reuse_address 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);
#ifdef WiN32
int fd = me->_acceptor.native_handle();
BOOL value = 1;
setsockopt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, &value, sizeof(BOOL));
#endif
me->_acceptor.accept(*socket);
std::function< void() > tf = [=]()


Loading…
Cancel
Save