Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bugfix: register signal handler before starting the server#864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 1 commit intocpp-netlib:masterfrommtrenkmann:fix-echo-async-server-example
Nov 26, 2018
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Start server after register signal handler
  • Loading branch information
@mtrenkmann
mtrenkmann committedNov 20, 2018
commit9080adac454356d62c416853f3fb6310faf8e0c9
7 changes: 6 additions & 1 deletionlibs/network/example/http/echo_async_server.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -224,16 +224,21 @@ int main() {
auto io_service = std::make_shared<boost::asio::io_service>();
echo_serverserver(
echo_server::options(handler).io_service(io_service).port("8000"));
server.run();

// Clean shutdown when pressing Ctrl+C.
boost::asio::signal_setsignals(*io_service, SIGINT, SIGTERM);
signals.async_wait([&server](const boost::system::error_code& ec,
int/* signal_number*/) {
if (!ec) {
std::cout <<"Stopping server...";
server.stop();
std::cout <<"done.\n";
}
});

std::cout <<"Press Ctrl+C to stop the server.\n";
server.run();

return EXIT_SUCCESS;
}catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp