Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7910385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:50:59+00:00 2026-06-03T12:50:59+00:00

I have a program with a Mono-based C# client and a Python server, which

  • 0

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.

My initial research hasn’t turned up anything that is obviously compatible across the 2 standard libraries. Python has a zlib library but I can’t use C#’s DeflateStream 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.)

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.

Ideally I’d like to keep external dependencies to a minimum, but I realise that may not be practical.

UPDATE: 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:51:02+00:00Added an answer on June 3, 2026 at 12:51 pm

    The BZip2 from SharpZipLib and Python’s library worked for me. Here’s what I tested and how:

    First, the C# program (referencing SharpZipLib):

    using System;
    using ICSharpCode.SharpZipLib.BZip2;
    using System.IO;
    
    namespace Test
    {
        class MainClass
        {
            public static void Main(string[] args)
            {
                var fStream = new FileStream("/home/konrad/output.bin", FileMode.Create);
                using(var writer = new StreamWriter(new BZip2OutputStream(fStream)))
                {
                    for(var i = 0; i < 10; i++)
                    {
                        writer.WriteLine("Line no {0}.", i);
                    }
                }
            }
        }
    
    }
    

    Then Python:

    from bz2 import BZ2File
    import sys
    
    f = BZ2File("/home/konrad/output.bin")
    for line in f.readlines():
        sys.stdout.write(line)
    

    Next, C# program is ran. And after that:

    $ python ctest.py
    Line no 0.
    Line no 1.
    Line no 2.
    Line no 3.
    Line no 4.
    Line no 5.
    Line no 6.
    Line no 7.
    Line no 8.
    Line no 9.
    

    I assume it works the other way round as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .Net program, which works fine using mono Program.exe, but now I
I have a program which I would like to run every X min the
I have a program which runs an external, command line utility and reads the
I have a mono android project. I can use monodevelop to build the apk
I have a program written in C#, running on Linux using Mono. The program
I want to use Mono to allow my C# program (currently WPF but will
I have a program which executes constantly and I need to save data every
I need to write an anaglyph images program. Let say I have two mono-color
I have program which loads an assembly using Asssembly.LoadFrom method. Some time later I
I have program which has servers interacting with each other using Twisted's remote procedure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.