This is really just a special case of the first solution, but it also lets you experiment with connecting to different machines. Third, we can use threads. If you run the client and server in two separate processes, you will. That concludes our first example. The server and client in the first example ran only once.
Typical servers run forever, accepting and servicing requests as they arrive.
We'll create such a server as our second example. We will once again build a client-server combination. The server generates token numbers, much like the machines that issue serial numbers to people in queues. The server initializes at zero, and each request generates the next token number. The client is a function that consumes one argument, which is the number of tokens to receive.