• Stars
    star
    1,356
  • Rank 34,645 (Top 0.7 %)
  • Language
    Python
  • Created almost 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Foundations of Python Network Programming (Apress) — scripts and examples

Foundations of Python Network Programming

Welcome!

This GitHub repository offers all of the example Python code from the Third Edition of Foundations of Python Network Programming as revised by Brandon Rhodes for Python 3:

From Amazon.com (affiliate link)
From Apress (the publisher)

Each chapter’s source code lives in its own directory:

Most of this works under Python 2

If you are still using Python 2, you will still benefit from studying these examples as they are more carefully designed than the scripts in the previous edition and also use more modern third-party libraries.

The README.md inside each chapter directory — which GitHub will display automatically when you click a chapter title in the Table of Contents above — has a paragraph near the top stating whether the scripts work with Python 2 or not. Typically each script needs only a quick run through the 3to2 tool in order to operate flawlessly under the old version of the language.

The exceptions are:

  • The TLS/SSL examples in Chapter 6 are specific to Python 3.4 and later because only with that version of the language did the ssl module gain safe enough defaults to be recommended for use with secure services. (An effort to backport these features to Python 2.7, however, does seem to be underway.)

  • Two of the scripts in Chapter 8 run into a snag if translated to Python 2 because of modules that have switched whether they want to operate on bytes or on Unicode strings.

  • The email scripts in Chapter 12 use a new and more convenient API that was added to the language in Python 3.4.

The other changes between Python 2 and 3 will be handled automatically by 3to2: print() is now a function, plain b'byte strings' now take a leading b, and many Standard Library modules were renamed during the transition.

The Network Playground

Many novice network programmers do not have interesting networks to explore — many homes have only a laptop plus a broadband modem to which the homeowner does not have access.

To remedy this situation, I have developed an entire Network Playground consisting of more than a half dozen hosts providing services from SSH and Telnet to a web server and FTP. The “hosts” are built using Docker, and I hope soon to package the whole thing up as a virtual machine that users can download.

The result will be that the user can get a prompt from which they can connect out to the example.com server farm and talk to all kinds of network services. And just as in a real network, they will find that these machines are several hops away — hops that can be inspected by normal networking tools like traceroute:

$ ssh h1

# traceroute www.example.com
traceroute to www.example.com (10.130.1.4), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  0.513 ms  0.208 ms  0.265 ms
 2  isp (10.25.1.1)  0.544 ms  0.220 ms  0.115 ms
 3  backbone (10.1.1.1)  0.364 ms  0.227 ms  0.252 ms
 4  example.com (10.130.1.1)  0.617 ms  0.355 ms  0.407 ms
 5  www.example.com (10.130.1.4)  1.301 ms  0.415 ms  0.522 ms

You can find the instructions here: The Network Playground.

More Repositories

1

python-patterns

Source code behind the python-patterns.guide site by Brandon Rhodes
Python
1,256
star
2

pycon-pandas-tutorial

PyCon 2015 Pandas tutorial materials
Jupyter Notebook
1,016
star
3

pyephem

Scientific-grade astronomy routines for Python
C
737
star
4

python-sgp4

Python version of the SGP4 satellite position library
Python
345
star
5

logging_tree

Debug Python logging problems by printing out the tree of handlers you have defined.
Python
302
star
6

Concentric-CSS

A standard order for CSS properties that starts at the outer edge of the box model and moves inward
CSS
296
star
7

homedir

My home directory dotfiles and customizations
Perl
201
star
8

python-typesetting

A Python library letting you invoke TeX-inspired typesetting algorithms
Python
156
star
9

sphinx-tutorial

Exercises for the Sphinx Tutorial that I used to present each year at PyCon
Python
154
star
10

python-adventure

Original Colossal Caves adventure game, but in Python 3
Python
148
star
11

python-jplephem

Python version of NASA DE4xx ephemerides, the basis for the Astronomical Alamanac
Python
103
star
12

unixpc-font-bdf

Convert the venerable AT&T UNIX PC font to the modern BDF bitmap format
Python
75
star
13

uncommitted

Command-line tool to find projects whose changes have not been committed to version control
Python
74
star
14

luca

Bookkeeping in Python
Python
67
star
15

scrawler

ASCII art animation library for Python
Python
64
star
16

pycon-sql-tutorial

Resources for my PyCon SQL tutorial
Python
52
star
17

python-novas

The United States Naval Observatory NOVAS astronomy library for Python
C
42
star
18

exe-from-python

Python
34
star
19

assay

Attempt to write a Python testing framework I can actually stand
Python
24
star
20

pycon2010-mighty-dictionary

Slides, dict introspection, and dict diagramming tools for my PyCon 2010 Talk “The Mighty Dictionary”
HTML
22
star
21

pyzmq-static

Script to compile a statically-linked version of the Python "zmq" package with ØMQ and libuuid (on Linux systems) built-in instead of relying on shared libraries.
C
22
star
22

dot-emacs

My self-booting .emacs.d directory, mostly for Python and JavaScript development
Emacs Lisp
18
star
23

contingent

The Contingent library for powering a build system with dynamic rules
HTML
11
star
24

gps-to-html

Static site generator that turns GPS tracks into maps and statistics
Python
7
star
25

backpacking-planner

Simple Python script to tally mileages between campgrounds and water sources
Python
7
star
26

blog

Source code for my personal blog
Jupyter Notebook
6
star
27

publicanus

Prototype small business tax calculation for Django Dash 2012
Python
6
star
28

pywinner

Set up a Windows EC2 instance to build Python packages
Python
5
star
29

personal-search-engine

Local and searchable cache of favorite tweets and bookmarked web pages
Python
4
star
30

conda-install

Install Conda packages right from your requirements.txt file
Python
3
star
31

assert_rewriter

Rewrite assert statements in Python bytecode so they support introspection
Python
3
star
32

trace-memory-access

Scripts to trace memory accesses from a program
Python
3
star
33

python-johnhancock

Sign a PDF document with a signature.png file
Python
2
star
34

twiddler-1-driver

Linux driver for original Handykey Twiddler chording keyboard
C
2
star
35

brandon-garmin

Simple Garmin apps for backcountry navigation
Monkey C
2
star
36

website-dillers-flooring

A web site for Diller's Flooring in Bluffton, Ohio
JavaScript
2
star
37

backports

2
star
38

python-spk

A library for parsing and loading SPK files
Python
2
star
39

cmr

cmr
2
star
40

pycon2010-sphinx-tutorial

Python
1
star
41

recursive-family-search

Find out when relatives reached this continent
Python
1
star
42

org-mode-invoicer

Python program to write up an invoice using org-mode
Python
1
star
43

build-butchart-map-index

Scripts to build a map index on my web site
HTML
1
star
44

talk-about-luca

Sample code for my May 2016 Clepy talk
Jupyter Notebook
1
star
45

rhodesmill.org

Personal website, for GitHub Pages
HTML
1
star