O'Reilly logo

The Sockets Networking API: UNIX® Network Programming Volume 1, Third Edition by Andrew M. Rudoff, Bill Fenner, W. Richard Stevens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. TCP Client/Server Example

Introduction

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:

  1. The client reads a line of text from its standard input and writes the line to the server.

  2. The server reads the line from its network input and echoes the line back to the client.

  3. 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.

Simple echo client and server.

Figure 5.1. Simple echo client and server.

We show two arrows between the client ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required