MCPcopy Create free account
hub / github.com/boostorg/beast / test_server

Method test_server

test/beast/core/basic_stream.cpp:185–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183
184public:
185 test_server(
186 string_view s,
187 net::ip::tcp::endpoint ep,
188 std::ostream& log)
189 : s_(s)
190 , log_(log)
191 , ioc_(1)
192 , acceptor_(ioc_)
193 , socket_(ioc_)
194 {
195 boost::system::error_code ec;
196
197 acceptor_.open(ep.protocol(), ec);
198 if(ec)
199 {
200 fail(ec, "open");
201 return;
202 }
203
204 acceptor_.set_option(
205 net::socket_base::reuse_address(true), ec);
206 if(ec)
207 {
208 fail(ec, "set_option");
209 return;
210 }
211
212 acceptor_.bind(ep, ec);
213 if(ec)
214 {
215 fail(ec, "bind");
216 return;
217 }
218
219 acceptor_.listen(
220 net::socket_base::max_listen_connections, ec);
221 if(ec)
222 {
223 fail(ec, "listen");
224 return;
225 }
226
227 acceptor_.async_accept(socket_,
228 [this](error_code ec)
229 {
230 this->on_accept(ec);
231 });
232
233 t_ = std::thread(
234 [this]
235 {
236 ioc_.run();
237 });
238 }
239
240 ~test_server()
241 {

Callers

nothing calls this directly

Calls 6

on_acceptMethod · 0.95
threadClass · 0.85
openMethod · 0.80
set_optionMethod · 0.80
failFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected