@@ -42,6 +42,7 @@ struct async_server_base : server_storage_base, socket_options_base {
4242 handler(options.handler()),
4343 address_(options.address()),
4444 port_(options.port()),
45+ protocol_(options.protocol()),
4546 thread_pool(options.thread_pool()
4647 ? options.thread_pool()
4748 : std::make_shared<utils::thread_pool>()),
@@ -108,11 +109,19 @@ struct async_server_base : server_storage_base, socket_options_base {
108109 }
109110 }
110111
112+ // / Returns the server socket address, either IPv4 or IPv6 depending on
113+ // / server_options.protocol()
114+ const string_type& address () const { return address_; }
115+
116+ // / Returns the server socket port
117+ const string_type& port () const { return port_; }
118+
111119 private:
112120 typedef std::unique_lock<std::mutex> scoped_mutex_lock;
113121
114122 Handler &handler;
115123 string_type address_, port_;
124+ boost::asio::ip::tcp protocol_;
116125 std::shared_ptr<utils::thread_pool> thread_pool;
117126 boost::asio::ip::tcp::acceptor acceptor;
118127 bool stopping;
@@ -165,7 +174,7 @@ struct async_server_base : server_storage_base, socket_options_base {
165174 // this allows repeated cycles of run -> stop -> run
166175 service_.reset ();
167176 tcp::resolver resolver (service_);
168- tcp::resolver::query query (address_, port_);
177+ tcp::resolver::query query (protocol_, address_, port_);
169178 tcp::resolver::iterator endpoint_iterator = resolver.resolve (query, error);
170179 if (error) {
171180 BOOST_NETWORK_MESSAGE (" Error resolving '" << address_ << ' :' << port_);
@@ -185,6 +194,8 @@ struct async_server_base : server_storage_base, socket_options_base {
185194 << port_);
186195 return ;
187196 }
197+ address_ = acceptor.local_endpoint ().address ().to_string ();
198+ port_ = std::to_string (acceptor.local_endpoint ().port ());
188199 acceptor.listen (boost::asio::socket_base::max_connections, error);
189200 if (error) {
190201 BOOST_NETWORK_MESSAGE (" Error listening on socket: '"
0 commit comments