Learning Python Network Programming

(Sean Pound) #1
Chapter 1

Protocols may even become their own layers, where an application protocol is built
on top of another application protocol. An example of this is the Simple Object
Access Protocol (SOAP), which defines an XML-based protocol that can be used
over almost any transport, including HTTP and SMTP.


Python has standard library modules for many application layer protocols and
third-party modules for many more. If we write low-level server applications, then
we will be more likely to be interested in TCP and UDP, but if not, then application
layer protocols are the ones we'll be working with, and we'll be looking at some of
them in detail over the next few chapters.


On to Python!


Well, that's it for our rundown of the TCP/IP stack. We'll move on to the next section
of this chapter, where we'll look at how to start using Python and how to work with
some of the topics we've just covered.


Network programming with Python


In this section, we're going to look at the general approach to network programming
in Python. We'll look at how Python lets us interface with the network stack, how to
track down useful modules, and cover some general network programming tips.


Breaking a few eggs


The power of the layer model of network protocols is that a higher layer can easily
build on the services provided by the lower layers and this enables them to add new
services to the network. Python provides modules for interfacing with protocols
at different levels in the network stack, and modules that support higher-layer
protocols follow the aforementioned principle by using the interfaces supplied
by the lower level protocols. How can we visualize this?


Well, sometimes a good way to see inside something like this is by breaking it. So,
let's break Python's network stack. Or, more specifically, let's generate a traceback.

Free download pdf