We will now use the elementary functions from the previous chapter to write a complete TCP client/server example. Our simple example is an echo server that performs the following steps:
The client reads a line of text from its standard input and writes the line to the server.
The server reads the line from its network input and echoes the line back to the client.
The client reads the echoed line and prints it on its standard output.
Figure 5.1 depicts this simple client/server along with the functions used for input and output.
Figure 5.1. Simple echo client and server.
We show two arrows between the client ...