server.hpp | server.hpp | |||
---|---|---|---|---|
skipping to change at line 657 | skipping to change at line 657 | |||
serv6_sock.reset(NULL); | serv6_sock.reset(NULL); | |||
} | } | |||
} | } | |||
template<typename selector_type> | template<typename selector_type> | |||
void basic_server<selector_type>::reopen_impl(unsigned int port, bool ipv6) | void basic_server<selector_type>::reopen_impl(unsigned int port, bool ipv6) | |||
{ | { | |||
selector_type& selector = basic_object<selector_type>::get_selector( ); | selector_type& selector = basic_object<selector_type>::get_selector( ); | |||
// Open IPv4 socket on local port | // Open IPv4 socket on local port | |||
if(!ipv6) | if(ipv6) | |||
{ | { | |||
ipv4_address bind_addr(port); | ipv6_address bind_addr(port); | |||
serv_sock.reset(new tcp_server_socket(bind_addr) ); | serv6_sock.reset(new tcp_server_socket(bind_addr) ); | |||
selector.set(*serv_sock, | selector.set(*serv6_sock, | |||
selector.get(*serv_sock) | IO_INCOMING | selector.get(*serv6_sock) | IO_INCOMING | |||
); | ); | |||
serv_sock->io_event().connect( | serv6_sock->io_event().connect( | |||
sigc::bind<0>( | sigc::bind<0>( | |||
sigc::mem_fun( | sigc::mem_fun( | |||
*this, | *this, | |||
&basic_server::on_accept_event | &basic_server::on_accept_event | |||
), | ), | |||
sigc::ref(*serv_sock) | sigc::ref(*serv6_sock) | |||
) | ) | |||
); | ); | |||
} | } | |||
else | ||||
// This might fail if bindv6only | ||||
// (/proc/sys/net/ipv6/bindv6only) is 0 | ||||
try | ||||
{ | { | |||
ipv6_address bind_addr(port); | ipv4_address bind_addr(port); | |||
serv6_sock.reset(new tcp_server_socket(bind_addr) ); | serv_sock.reset(new tcp_server_socket(bind_addr) ); | |||
selector.set(*serv6_sock, | selector.set(*serv_sock, | |||
selector.get(*serv6_sock) | IO_INCOMING | selector.get(*serv_sock) | IO_INCOMING | |||
); | ); | |||
serv6_sock->io_event().connect( | serv_sock->io_event().connect( | |||
sigc::bind<0>( | sigc::bind<0>( | |||
sigc::mem_fun( | sigc::mem_fun( | |||
*this, | *this, | |||
&basic_server::on_accept_event | &basic_server::on_accept_event | |||
), | ), | |||
sigc::ref(*serv6_sock) | sigc::ref(*serv_sock) | |||
) | ) | |||
); | ); | |||
} | } | |||
catch(const net6::error& ex) | ||||
{ | ||||
if(!ipv6) throw ex; | ||||
} | ||||
} | } | |||
} // namespace net6 | } // namespace net6 | |||
#endif // _NET6_SERVER_HPP_ | #endif // _NET6_SERVER_HPP_ | |||
End of changes. 11 change blocks. | ||||
14 lines changed or deleted | 21 lines changed or added | |||