Added ability for sockets to override their byte counters

This commit is contained in:
Thulinma 2017-02-01 15:31:14 +01:00
parent 6f08fcd371
commit 23f0c388b5
2 changed files with 10 additions and 0 deletions

View file

@ -237,6 +237,14 @@ void Socket::Connection::resetCounter(){
down = 0; 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. /// Internally used call to make an file descriptor blocking or not.
void setFDBlocking(int FD, bool blocking){ void setFDBlocking(int FD, bool blocking){
int flags = fcntl(FD, F_GETFL, 0); int flags = fcntl(FD, F_GETFL, 0);

View file

@ -94,6 +94,8 @@ namespace Socket{
uint64_t dataUp(); ///< Returns total amount of bytes sent. uint64_t dataUp(); ///< Returns total amount of bytes sent.
uint64_t dataDown(); ///< Returns total amount of bytes received. uint64_t dataDown(); ///< Returns total amount of bytes received.
void resetCounter(); ///< Resets the up/down bytes counter to zero. 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. std::string getStats(std::string C); ///< Returns a std::string of stats, ended by a newline.
friend class Server; friend class Server;
bool Error; ///< Set to true if a socket error happened. bool Error; ///< Set to true if a socket error happened.