I need to make a statistical printout of a socket program.
I am using method Listen(uint32_t port) in c++ thread to listen to clients on the specified port (more than one) and send/receive client's transactions to/from a server.
Now i need to write a log file of how many packet received/sent by this method. To do this I created a global variable say map x. and increase x for the corresponding port ever time the packet are received/sent.
Now i need to get the information from x while the program is still running.
I thought of two options:
- Access the packet counter from an external program-> like define a method that can get the packet information while the thread is till running
problem: I don't know if i can access a variable/method in a running program.
- or print the info to a log file every 5 seconds.
problem: I don't know if it makes sense to have a timer in the multiple thread.
Please any advice will be appreciated
Kehinde
Aucun commentaire:
Enregistrer un commentaire