Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good Python networking libraries for building a TCP server?

I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me.

Also, would using Twisted even have a benefit over rolling my own server with select.select()?

like image 562
ryeguy Avatar asked Jan 14 '09 03:01

ryeguy


People also ask

Which Python library is used for networking?

1. Netmiko. Netmiko is an exceptional Python library developed by Kirk Byers designed to act as an abstraction layer over the Paramiko Python implementation of the SSHv2 protocol. In effect, Netmiko is Paramiko reimagined and adapted to interact with networking devices specifically.

Which library is used for network programming?

Network programming is one of my favorite Python applications. I wrote or started most of the network modules in the Python standard library, including the socket and select extension modules and most of the protocol client modules (such as ftplib ), which set an example.


2 Answers

I must agree that the documentation is a bit terse but the tutorial gets you up and running quickly.

http://twistedmatrix.com/projects/core/documentation/howto/tutorial/index.html

The event-based programming paradigm of Twisted and it's defereds might be a bit weird at the start (was for me) but it is worth the learning curve.

You'll get up and running doing much more complex stuff more quickly than if you were to write your own framework and it would also mean one less thing to bug hunt as Twisted is very much production proven.

I don't really know of another framework that can offer as much as Twisted can, so my vote would definitely go for Twisted even if the docs aren't for the faint of heart.

I agree with Greg that SocketServer is a nice middle ground but depending on the target audience of your application and the design of it you might have some nice stuff to look forward to in Twisted (the PerspectiveBroker which is very useful comes to mind - http://twistedmatrix.com/projects/core/documentation/howto/pb-intro.html)

like image 97
pboucher Avatar answered Sep 19 '22 10:09

pboucher


The standard library includes SocketServer and related modules which might be sufficient for your needs. This is a good middle ground between a complex framework like Twisted, and rolling your own select() loop.

like image 24
Greg Hewgill Avatar answered Sep 17 '22 10:09

Greg Hewgill