Chapter 17. Data in Space: Networks

Time is nature’s way of keeping everything from happening at once. Space is what prevents everything from happening to me.

Quotes About Time

In Chapter 15, you read about concurrency: how to do more than one thing at a time. Now we’ll try to do things in more than one place: distributed computing or networking. There are many good reasons to challenge time and space:


Your goal is to keep fast components busy, not waiting for slow ones.


There’s safety in numbers, so you want to duplicate tasks to work around hardware and software failures.


It’s best practice to break complex tasks into many little ones that are easier to create, understand, and fix.


Increase your servers to handle load, decrease them to save money.

In this chapter, we work our way up from networking primitives to higher-level concepts. Let’s start with TCP/IP and sockets.


The internet is based on rules about how to make connections, exchange data, terminate connections, handle timeouts, and so on. These are called protocols, and they are arranged in layers. The purpose of layers is to allow innovation and alternative ways of doing things; you can do anything you want on one layer as long as you follow the conventions in dealing with the layers above and below you.

The very lowest layer governs aspects such as electrical signals; each higher layer builds on those below. In the middle, more or less, is the IP (Internet ...

Get Introducing Python, 2nd Edition 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.