libnhttp/nhttp/net/base/listener_base.cpp
/* register new listening IPv6 address and ports. */
register new listening IPv6 address and ports.
register new listening IPv6 address and ports .
bool listener_base::with(const ipv6& ep) {
		socket_t sock = socket_t::create<ipv6_addr, tcp>();
		hal::socket_raw_t raw = sock.get_raw();
		if (!sock) {
			return false;
		}
		if (!sock.bind(ep)) {
			sock.close();
			return false;
		}
		raw.set_non_blocking(true);
		raw.set_reuse_address(true);
		if (!sock.listen(10)) {
			sock.close();
			return false;
		}
		sock.set_tag(dynamic_cast<listener_base*>(this), nullptr);
		sources.push_back(sock);
		watcher.watch(sock, [](socket_t sock) {
			if (sock.can_read()) {
				((listener_base*)sock.get_tag())
					->on_newbie(sock);
			}
		});
		return true;
	}
bool listener_base :: with ( const ipv6 & ep ) { socket_t sock = socket_t :: create < ipv6_addr , tcp > ( ) ; hal :: socket_raw_t raw = sock . get_raw ( ) ; if ( ! sock ) { return false ; } if ( ! sock . bind ( ep ) ) { sock . close ( ) ; return false ; } raw . set_non_blocking ( true ) ; raw . set_reuse_address ( true ) ; if ( ! sock . listen ( 10 ) ) { sock . close ( ) ; return false ; } sock . set_tag ( dynamic_cast < listener_base * > ( this ) , nullptr ) ; sources . push_back ( sock ) ; watcher . watch ( sock , [ ] ( socket_t sock ) { if ( sock . can_read ( ) ) { ( ( listener_base * ) sock . get_tag ( ) ) -> on_newbie ( sock ) ; } } ) ; return true ; }
register new listening IPv6 address and ports.
register new listening IPv6 address and ports .