From 362a71f445f218b1d54576989c88ad450c9e5905 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 7 Nov 2010 22:03:51 +0100 Subject: Add error argument to Connection::handle_read(). --- server/connection.cpp | 8 ++++++-- server/connection.h | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/connection.cpp b/server/connection.cpp index f846d3b..32b24da 100644 --- a/server/connection.cpp +++ b/server/connection.cpp @@ -6,7 +6,11 @@ Connection::Connection(boost::asio::io_service& io_service) : socket(io_service) } -void Connection::handle_read(uint8_t* data, std::size_t bytes) { +void Connection::handle_read(uint8_t* data, std::size_t bytes, const boost::system::error_code& error) { + if(error) { + return; + } + got_data(data, bytes); delete[] data; @@ -20,7 +24,7 @@ void Connection::request_data(std::size_t bytes) { uint8_t* buf = new uint8_t[bytes]; boost::asio::async_read(socket, boost::asio::buffer(buf, bytes), - boost::bind(&Connection::handle_read, shared_from_this(), buf, bytes)); + boost::bind(&Connection::handle_read, shared_from_this(), buf, bytes, boost::asio::placeholders::error)); // boost::asio::placeholders::error } diff --git a/server/connection.h b/server/connection.h index aba7734..b6a3cd3 100644 --- a/server/connection.h +++ b/server/connection.h @@ -13,10 +13,9 @@ class Connection : public ConnectionBase, public boost::enable_shared_from_this< boost::asio::ip::tcp::socket socket; Connection(boost::asio::io_service& io_service); - - private: + //! Callback for when data is read. - void handle_read(uint8_t* data, std::size_t bytes); + void handle_read(uint8_t* data, std::size_t bytes, const boost::system::error_code& error); //! Callback for when data is written. void handle_write(); -- cgit v1.2.3