Skip to content

Commit

Permalink
Fixed a few typos in chapter06 and sync recipe03 in chapter06 with th…
Browse files Browse the repository at this point in the history
…e book
  • Loading branch information
apolukhin committed May 24, 2017
1 parent 61a5402 commit f7f451e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void async_read_data(connection_ptr&& c, const Functor& f, std::size_t at_least_


template <class Functor>
void async_read_dataat_least(connection_ptr&& c, const Functor& f, std::size_t at_least_bytes, std::size_t at_most = 4095) {
void async_read_data_at_least(connection_ptr&& c, const Functor& f, std::size_t at_least_bytes, std::size_t at_most) {
std::string& d = c->data;
d.resize(at_most);
char* p = (at_most == 0 ? 0 : &d[0]);
Expand Down
2 changes: 1 addition & 1 deletion Chapter06/04_tasks_processor_network_accept/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class authorizer {
public:
static void on_connection_accpet(connection_ptr&& connection, const boost::system::error_code& error) {
assert(!error);
async_read_dataat_least(std::move(connection), &authorizer::on_datarecieve, 1);
async_read_data_at_least(std::move(connection), &authorizer::on_datarecieve, 1, 1024);
}

static void on_datarecieve(connection_ptr&& connection, const boost::system::error_code& error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class tasks_processor: public tp_network_client::tasks_processor {
typedef boost::asio::ip::tcp::acceptor acceptor_t;
typedef boost::function<void(connection_ptr, const boost::system::error_code&)> on_accpet_func_t;

private:
struct tcp_listener {
acceptor_t acceptor_;
const on_accpet_func_t func_;
Expand All @@ -28,6 +29,7 @@ class tasks_processor: public tp_network_client::tasks_processor {
};
typedef std::unique_ptr<tcp_listener> listener_ptr;

private:
struct handle_accept {
listener_ptr listener;

Expand All @@ -46,6 +48,7 @@ class tasks_processor: public tp_network_client::tasks_processor {
}
};

private:
static void start_accepting_connection(listener_ptr&& listener) {
if (!listener->acceptor_.is_open()) {
return;
Expand Down

0 comments on commit f7f451e

Please sign in to comment.