Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: IdTCPServer Tokyo - Total session Received-Sent Byte Count


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Dec 8, 2017 10:23 AM Last Post By: Remy Lebeau (Te...
craig kenny

Posts: 1
Registered: 12/7/15
IdTCPServer Tokyo - Total session Received-Sent Byte Count  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2017 10:16 PM
Hello all, appreciate any advice on how I may get the total inbound outbound byte counts for a connected client session. I am unable to find my way and any pointers in the right direction would help please.
I am only using basic AContext.Connection.IOHandler.ReadLn(); AContext.Connection.IOHandler.WriteLn(); as I am not an advanced coder.

Thanks
Craig.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: IdTCPServer Tokyo - Total session Received-Sent Byte Count  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2017 10:23 AM   in response to: craig kenny in response to: craig kenny
craig kenny wrote:

Hello all, appreciate any advice on how I may get the total inbound
outbound byte counts for a connected client session.

Indy does not keep track of that information, unless you manually call
the TIdTCPComponent.BeginWork() method, in which case you will then get
OnWork events containing the total byte count since BeginWork() was
called.

Otherwise, you will have to track the counts manually. For instance,
you could assign a TIdConnectionIntercept to the connection's Intercept
property, and then use the Intercept's OnReceive and OnSend events to
count the bytes in both directions.

On Windows Vista and later, you can alternatively use WinSock's own
GetPerTcpConnectionEStats() and GetPerTcp6ConnectionEStats() functions
to collection statistical data for a given TCP connection:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb485738.aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/bb485735.aspx

Or you can use the ETW API to monitor EVENT_TRACE_FLAG_NETWORK_TCPIP
network events from KERNEL_LOGGER_NAME.

See:

how to count bytes sent and received per TCP connection (system-wide)?
https://stackoverflow.com/questions/4705292/

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02