1
Chapter 1
Introduction to Client-Server
Networking
This book explores network programming in the Python language. It covers the basic concepts, modules, and
third-party libraries that you are likely to use when communicating with remote machines using the most popular
Internet communication protocols.
The book lacks the space to teach you how to program in Python if you have never seen the language before or if
you have never even written a computer program at all; it presumes that you have already learned something about
Python programming from the many excellent tutorials and books on the subject. I hope that the Python examples
in the book give you ideas about how to structure and write your own code. But I will be using all sorts of advanced
Python features without explanation or apology—though, occasionally, I might point out how I am using a particular
technique or construction when I think it is particularly interesting or clever.
On the other hand, this book does not start by assuming you know any networking! As long as you have ever used
a web browser or sent an e-mail, you should know enough to start reading this book at the beginning and learn about
computer networking along the way. I will approach networking from the point of view of an application programmer
who is either implementing a network-connected service—such as a web site, an e-mail server, or a networked
computer game—or writing a client program that is designed to use such a service.
Note that you will not, however, learn how to set up or configure networks from this book. The disciplines
of network design, server room management, and automated provisioning are full topics all on their own, which
tend not to overlap with the discipline of computer programming as covered in this particular book. While Python
is indeed becoming a big part of the provisioning landscape thanks to projects such as OpenStack, SaltStack, and
Ansible, you will want to search for books and documentation that are specifically about provisioning and its many
technologies if you want to learn more about them.
The Building Blocks: Stacks and Libraries
As you begin to explore Python network programming, there are two concepts that will appear over and over again.
• The idea of a protocol stack, in which simpler network services are used as the foundation on
which to build more sophisticated services.
• The fact that you will often be using Python libraries of previously written code—whether
modules from the built-in standard library that ships with Python or packages from third-party
distributions that you download and install—that already know how to speak the network
protocol that you want to use.