title: Easiest way to compress in Python and decompress with decompress C# (and vice versa)
body: <p>I have a program with a Mono-based C# client and a Python server, which communicate over a TCP/IP socket. The messages use a mostly binary format but the largest part of each message is usually embedded UTF-8 strings (in English). Each message is typically short (under 100 bytes) but some can be longer (up to 64K). A lot of data is exchanged and I'd like to reduce message sizes and bandwidth usage by compressing the data when it's transmitted.</p>
  
  <p>My initial research hasn't turned up anything that is obviously compatible across the 2 standard libraries. Python has a <a href="http://docs.python.org/library/zlib.html" rel="nofollow">zlib</a> library but I can't use C#'s <a href="http://msdn.microsoft.com/en-us/library/system.io.compression.deflatestream.aspx" rel="nofollow">DeflateStream</a> or GZipStream (as they require an external DLL that I don't have available) and it doesn't seem to work with SharpZipLib's ZipOutputStream (giving out "error -3 - incorrect header" responses). (Those not using Mono might have more luck - see Duncan's answer below.)</p>
  
  <p>I would be interested in hearing about easy ways to enable compression over this communications link, bearing in mind that any solution that may be easy to implement in one language needs to have an equivalent in the other. I'd accept a solution that is specialised towards the UTF-8 strings rather than the binary messages although the preference would be to compress the whole byte stream.</p>
  
  <p>Ideally I'd like to keep external dependencies to a minimum, but I realise that may not be practical.</p>
  
  <p>UPDATE: <em>Having tried with SharpZipLib and encountered repeated errors on the Python decoding side, I could really do with concrete suggestions with code that is known to work rather than just suggestions of compression libraries for one language or the other.</em></p>