views:

149

answers:

4

I was wondering what good networking libraries/frameworks there are for Python.

Please provide a link to the standard API documentation for the library, and perhaps a link to a decent tutorial to get started with it.

A comment or two about its advantages/disadvantages would be nice as well.

+3  A: 

Twisted is the most complete, and complex, of all Python networking frameworks.

It's well-established and very complete, but it has a steep learning curve.

Documentation here; FAQ here.

RichieHindle
+4  A: 

Consider the Twisted framework. The advantage:

  • solid reactor implementation
  • support for almost all network protocols found in the wild
  • well documented

Disadvantages:

  • it's huge
  • the asynchronous APIs need some time to get used to (but once you are familiar, things are actually pretty usable)

CPython itself ships with a tiny reactor/socket package. Never used it myself, though.

Dirk
twisted is not huge, that's a misconception I can't get where it came from. I just added the size of .py files in my twisted copy and got only 9.7MB. That is **very small** , considering that most hard drives being sold today are >= 500GB. Even cell phones have this easily available. And for less than 10MB, I got support to almost every protocol found in the wild. I could remove parts of it to make it smaller but it is hardly worth the few MB I would save. Please clarify what you mean with *huge* .
nosklo
That's pretty large in terms of the time it would take to code or understand it, the number of functions it provides, or the number of subtly different ways you could use it.
jnylen
Huge as in vast, not necessarily huge as in file size. The library can be stripped down by just about any optimizer if disk space is actually an issue.
Soviut
+4  A: 

The standard library has asyncore which is good for very simple stuff as well as the SocketServer stuff if you'd prefer something that does threads. There's also Twisted but the barrier of entry to that is a bit high if you're not used to event-driven IO. If you're after web frameworks, CherryPy is a good start or there's Django and TurboGears if you're looking for something more full-featured.

Benno
A: 

In case you want to build/manipulate your own packets there is Scapy too :)

The usage is pretty straight forward, it lets you do whatever you want with the packets and it's multi-Platform.

Project Page: http://www.secdev.org/projects/scapy/

Docs: http://www.secdev.org/projects/scapy/doc/

Example: http://www.secdev.org/projects/scapy/demo.html

Birt