An echo protocol

Before we write our first client and server programs, we need to decide how they are going to interact with each other, that is we need to design a protocol for their communication.

Our echo server should listen until a client connects and sends a bytes string, then we want it to echo that string back to the client. We only need a few basic rules for doing this. These rules are as follows:

  1. Communication will take place over TCP.
  2. The client will initiate an echo session by creating a socket connection to the server.
  3. The server will accept the connection and listen for the client to send a bytes string.
  4. The client will send a bytes string to the server.
  5. Once it sends the bytes string, the client will listen for a reply from the server ...

Get Learning Python Network Programming 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.