A typical client/server program flow chart
Stream-oriented socket programs generally follow a prescribed sequence. See Figure 1 for a diagram of the logic flow for a typical client and server. As you study this diagram, keep in mind the fact that a concurrent server typically starts before the client does, and waits for the client to request connection at step 3. It then continues to wait for additional client requests after the client connection is closed.