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

Commitd3f9ce2

Browse files
committed
Moving out TCP_NODELAY setting from connection constructor.
Moving it to start() instead of the constructor, removing reliance on exceptions.Fixes#6 .
1 parentbf60c4e commitd3f9ce2

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

‎boost/network/protocol/http/connection.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ namespace boost { namespace network { namespace http {
4545
, socket_(service_)
4646
, wrapper_(service_)
4747
{
48-
try {
49-
socket_.set_option(tcp::no_delay(true));// Don't delay writing
50-
}catch (system::system_error & e) {
51-
handler_.log(e.what());
52-
}
5348
}
5449

5550
tcp::socket &socket() {
@@ -62,6 +57,9 @@ namespace boost { namespace network { namespace http {
6257
// and then pass that request object to the
6358
// handler_ instance.
6459
//
60+
boost::system::error_code option_error;
61+
socket_.set_option(tcp::no_delay(true), option_error);
62+
if (option_error) handler_.log(system::system_error(option_error).what());
6563
socket_.async_read_some(
6664
boost::asio::buffer(buffer_),
6765
wrapper_.wrap(

‎libs/network/test/hello_world.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,26 @@ namespace http = boost::network::http;
1616
using boost::assign::list_of;
1717
using boost::lexical_cast;
1818
using std::string;
19+
using std::cerr;
20+
using std::endl;
1921

2022
structhello_world;
2123
typedef http::server<hello_world> server;
2224

2325
structhello_world {
26+
2427
voidoperator()(server::requestconst & request, server::response & response) {
2528
response =server::response::stock_reply(server::response::ok,"Hello, World!");
2629
assert(response.status == server::response::ok);
2730
assert(response.headers.size() ==2);
2831
assert(response.content =="Hello, World!");
2932
}
30-
voidlog(...) {
31-
// do nothing
33+
34+
voidlog(stringconst & data) {
35+
cerr << data << endl;
36+
abort();
3237
}
38+
3339
};
3440

3541
intmain(int argc,char * argv[]) {
@@ -38,3 +44,4 @@ int main(int argc, char * argv[]) {
3844
server_.run();
3945
return EXIT_SUCCESS;
4046
}
47+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp