Skip to content

Commit

Permalink
new recv and send count
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Oct 26, 2015
1 parent 145e7b7 commit 66a2f7c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/netius/base/conn.py
Expand Up @@ -590,23 +590,29 @@ class DiagConnection(BaseConnection):
def __init__(self, *args, **kwargs):
BaseConnection.__init__(self, *args, **kwargs)
self.creation = time.time()
self.recvs = 0
self.sends = 0
self.in_bytes = 0
self.out_bytes = 0

def recv(self, *args, **kwargs):
result = BaseConnection.recv(self, *args, **kwargs)
self.in_bytes += len(result)
self.recvs += 1
return result

def send(self, data, *args, **kwargs):
result = BaseConnection.send(self, data, *args, **kwargs)
self.out_bytes += len(data)
self.sends += 1
return result

def info_dict(self, full = False):
info = BaseConnection.info_dict(self, full = full)
info.update(
uptime = self._uptime(),
recvs = self.recvs,
sends = self.sends,
in_bytes = self.in_bytes,
out_bytes = self.out_bytes
)
Expand Down

0 comments on commit 66a2f7c

Please sign in to comment.