From 01215dc268a34f619c41082709abd1f79299a19d Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 15 Sep 2016 16:41:18 +0000
Subject: [PATCH] keep track of recv/send bytes

---
 Common/GmshSocket.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Common/GmshSocket.h b/Common/GmshSocket.h
index 1f19ae5f1f..e4dc1c540d 100644
--- a/Common/GmshSocket.h
+++ b/Common/GmshSocket.h
@@ -98,6 +98,8 @@ class GmshSocket{
   int _sock;
   // the socket name
   std::string _sockname;
+  // statistics
+  unsigned long int _sent, _received;
   // send some data over the socket
   int _SendData(const void *buffer, int bytes)
   {
@@ -110,6 +112,7 @@ class GmshSocket{
       sofar += len;
       remaining -= len;
     } while(remaining > 0);
+    _sent += bytes;
     return bytes;
   }
   // receive some data over the socket
@@ -125,6 +128,7 @@ class GmshSocket{
       sofar += len;
       remaining -= len;
     } while(remaining > 0);
+    _received += bytes;
     return bytes;
   }
   // utility function to swap bytes in an array
@@ -149,7 +153,7 @@ class GmshSocket{
 #endif
   }
  public:
-  GmshSocket() : _sock(0)
+  GmshSocket() : _sock(0), _sent(0), _received(0)
   {
 #if defined(WIN32) && !defined(__CYGWIN__)
     WSADATA wsaData;
@@ -250,6 +254,8 @@ class GmshSocket{
     shutdown(s, SHUT_RDWR);
 #endif
   }
+  unsigned long int SentBytes(){ return _sent; }
+  unsigned long int ReceivedBytes(){ return _received; }
 };
 
 class GmshClient : public GmshSocket {
-- 
GitLab