Coder Social home page Coder Social logo

adrcad / fopnp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brandon-rhodes/fopnp

0.0 2.0 1.0 2.83 MB

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

Makefile 0.66% Python 75.97% Ruby 0.06% Shell 4.42% HTML 18.49% JavaScript 0.08% CSS 0.32%

fopnp's Introduction

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:

$ ./play.sh 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

Follow this repository if you want to watch my progress towards making the install of the playground fully automated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.