96. Client-server Fizz-Buzz

In order to solve this problem, we will use the Asio library again. However, this time we need to write two programs: a server and a client. The server accepts TCP connections on a particular port, opens a connected socket, and starts reading on the socket. When it reads something from the socket, it interprets it as a number for the Fizz-Buzz game, writes back the answer, and continues to wait for another input. The client connects to a host on a particular port, sends a number read from the console, and then waits to receive an answer from the server before printing it to the console.

On the server side, the implementation of the Fizz-Buzz game is rather straightforward and should not require additional explanations. ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.