Skip to content

Commit 685810c

Browse files
committed
More efficient fileserver example.
This commit makes the fileserver example more efficient by eliminating the need for copying the data into multiple buffers and using the newly implemented less-copying overload for writing to connections.
1 parent 8f2276b commit 685810c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/network/example/http/fileserver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ struct connection_handler : boost::enable_shared_from_this<connection_handler> {
126126
std::size_t adjusted_offset = offset+4096;
127127
off_t rightmost_bound = std::min(mmaped_region.second, adjusted_offset);
128128
connection->write(
129-
boost::make_iterator_range(
129+
boost::asio::const_buffers_1(
130130
static_cast<char const *>(mmaped_region.first) + offset,
131-
static_cast<char const *>(mmaped_region.first) + rightmost_bound
131+
rightmost_bound
132132
)
133133
, boost::bind(
134134
&connection_handler::handle_chunk,

0 commit comments

Comments
 (0)