@@ -42,6 +42,7 @@ struct async_server_base : server_storage_base, socket_options_base {
42
42
handler(options.handler()),
43
43
address_(options.address()),
44
44
port_(options.port()),
45
+ protocol_(options.protocol()),
45
46
thread_pool(options.thread_pool()
46
47
? options.thread_pool()
47
48
: std::make_shared<utils::thread_pool>()),
@@ -108,11 +109,19 @@ struct async_server_base : server_storage_base, socket_options_base {
108
109
}
109
110
}
110
111
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
+
111
119
private:
112
120
typedef std::unique_lock<std::mutex> scoped_mutex_lock;
113
121
114
122
Handler &handler;
115
123
string_type address_, port_;
124
+ boost::asio::ip::tcp protocol_;
116
125
std::shared_ptr<utils::thread_pool> thread_pool;
117
126
boost::asio::ip::tcp::acceptor acceptor;
118
127
bool stopping;
@@ -165,7 +174,7 @@ struct async_server_base : server_storage_base, socket_options_base {
165
174
// this allows repeated cycles of run -> stop -> run
166
175
service_.reset ();
167
176
tcp::resolver resolver (service_);
168
- tcp::resolver::query query (address_, port_);
177
+ tcp::resolver::query query (protocol_, address_, port_);
169
178
tcp::resolver::iterator endpoint_iterator = resolver.resolve (query, error);
170
179
if (error) {
171
180
BOOST_NETWORK_MESSAGE (" Error resolving '" << address_ << ' :' << port_);
@@ -185,6 +194,8 @@ struct async_server_base : server_storage_base, socket_options_base {
185
194
<< port_);
186
195
return ;
187
196
}
197
+ address_ = acceptor.local_endpoint ().address ().to_string ();
198
+ port_ = std::to_string (acceptor.local_endpoint ().port ());
188
199
acceptor.listen (boost::asio::socket_base::max_connections, error);
189
200
if (error) {
190
201
BOOST_NETWORK_MESSAGE (" Error listening on socket: '"
0 commit comments