Good day. I have two processes, one of them is a client, the other is a server. It is necessary for me that they together in one file. As a result, in the log file I should get something like this:
bot1>sending message: hi! bot2>got message: hi! bot2>sending answer: hello you too bot1>got message: hello you too bot1>sending message: green bot2>got message: green bot2>sending answer: bonjourna bot1>got message: bonjourna bot1>got wrong message, expected: apple, received: bonjourna bot1>sending message: green bot2>got message: green bot2>sending answer: bonjourna bot1>got message: bonjourna bot1>got wrong message, expected: apple, received: bonjourna I decided to use the following algorithm:
1. The server opens the file, writes its log there, then closes the file.
2. The client opens the file, writes his log there, then closes the file.
3. The server opens the file, writes its own log there, then closes the file.
.... And so they do to the bitter end.
Please tell me how to implement such an algorithm?