Skip to content

Commit 8cafe88

Browse files
mtrenkmanndeanberris
authored andcommitted
Start server after register signal handler (#864)
1 parent e09e7ab commit 8cafe88

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libs/network/example/http/echo_async_server.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,21 @@ int main() {
224224
auto io_service = std::make_shared<boost::asio::io_service>();
225225
echo_server server(
226226
echo_server::options(handler).io_service(io_service).port("8000"));
227-
server.run();
228227

229228
// Clean shutdown when pressing Ctrl+C.
230229
boost::asio::signal_set signals(*io_service, SIGINT, SIGTERM);
231230
signals.async_wait([&server](const boost::system::error_code& ec,
232231
int /* signal_number */) {
233232
if (!ec) {
233+
std::cout << "Stopping server... ";
234234
server.stop();
235+
std::cout << "done.\n";
235236
}
236237
});
238+
239+
std::cout << "Press Ctrl+C to stop the server.\n";
240+
server.run();
241+
237242
return EXIT_SUCCESS;
238243
} catch (const std::exception& error) {
239244
std::cerr << error.what() << std::endl;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy