From 23f0c388b5c2dd0b4504165508b7eda5f66fefab Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 1 Feb 2017 15:31:14 +0100 Subject: [PATCH] Added ability for sockets to override their byte counters --- lib/socket.cpp | 8 ++++++++ lib/socket.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/socket.cpp b/lib/socket.cpp index 0daef3c0..ad70cb93 100644 --- a/lib/socket.cpp +++ b/lib/socket.cpp @@ -237,6 +237,14 @@ void Socket::Connection::resetCounter(){ down = 0; } +void Socket::Connection::addUp(const uint32_t i){ + up += i; +} + +void Socket::Connection::addDown(const uint32_t i){ + down += i; +} + /// Internally used call to make an file descriptor blocking or not. void setFDBlocking(int FD, bool blocking){ int flags = fcntl(FD, F_GETFL, 0); diff --git a/lib/socket.h b/lib/socket.h index 3f25a28d..0ebe0eb8 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -94,6 +94,8 @@ namespace Socket{ uint64_t dataUp(); ///< Returns total amount of bytes sent. uint64_t dataDown(); ///< Returns total amount of bytes received. void resetCounter(); ///< Resets the up/down bytes counter to zero. + void addUp(const uint32_t i); + void addDown(const uint32_t i); std::string getStats(std::string C); ///< Returns a std::string of stats, ended by a newline. friend class Server; bool Error; ///< Set to true if a socket error happened.