summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@sakuya.local>2010-11-07 22:03:51 +0100
committerVegard Storheil Eriksen <zyp@sakuya.local>2010-11-07 22:03:51 +0100
commit362a71f445f218b1d54576989c88ad450c9e5905 (patch)
tree07007b11e01673d918b2d01abbe5249246e723eb
parentaf224c809ab744be92ac610648640ca9d3e562fa (diff)
Add error argument to Connection::handle_read().
-rw-r--r--server/connection.cpp8
-rw-r--r--server/connection.h5
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();