zipped socket

Peter Hansen peter at engcorp.com
Mon Aug 8 14:19:22 CEST 2005


John wrote:
> 
> Is there anyway open a socket so that every send/listen/recv
> goes thru a zipping/unzipping process automatically?

You ought to be able to do this easily by wrapping a bz2 compressor 
around the socket (maybe using socket.makefile() to return a file object 
first) and probably using a generator as well:

http://effbot.org/librarybook/bz2.htm includes relevant examples (not 
specifically with sockets though).

Googling for "python incremental compression" ought to turn up any other 
alternatives.

-Peter



More information about the Python-list mailing list