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 6380501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:16:31+00:00 2026-05-25T02:16:31+00:00

I’m about serialize a paket with information, which act as an answer on a

  • 0

I’m about serialize a paket with information, which act as an answer on a incoming udp paket. The incoming UDP paket is very compact and contains exactly the information I want to see.

When I send my reply, the packet is nearly 200 times bigger (1036 byte against 57 byte..) and contains a lot of white spaces, name of the class instance and it’s structure (like nullable and so on).

The question may sounds wide but what are the problem here? I understand that my solution is serialize the whole object, including it’s class name, namespace and so on. The recipient don’t need, won’t and Can’t take this info. They need to go directly into the data structure.

  • 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-05-25T02:16:32+00:00Added an answer on May 25, 2026 at 2:16 am

    You should probably try out Protobuf. It supports the attributed serialization model (in fact, it supports several attributed models, including the DataContract WCF model), and is significantly faster than built-in .Net binary serialization (faster than even DataContract serialization). Protobuf is also designed to be as compact as possible – so you should have fewer problems with packet size.

    Edit: You could also implement your own serialization paradigm, by using an interface. For example:

    public interface IBinarySerializable
    {
        void Serialize(BinaryWriter writer);
        void Deserialize(BinaryReader reader);
    }
    
    public static class BinaryReaderWriterExtensions
    {
        public static void Write(this BinaryWriter writer, IBinarySerializable value)
        {
            value.Serialize(writer);
        }
    
        public static T Read<T>(this BinaryReader reader)
            where T : IBinarySerializable, new()
        {
            var val = new T();
            val.Deserialize(reader);
            return val;
        }
    
        public static void ReadInto(this BinaryReader reader, IBinarySerializable value)
        {
            value.Deserialize(reader);
        }
    
        public static void WriteList<T>(this BinaryWriter writer, IList<T> list, Action<BinaryWriter, T> singleValueWriter)
        {
            writer.Write(list.Count);
            foreach (var item in list)
                singleValueWriter(writer, item);
        }
    
        public static IEnumerable<T> ReadList<T>(this BinaryReader reader, Func<BinaryReader, T> singleValueReader)
        {
            var ct = reader.ReadInt32();
            for (var i = 0; i < ct; i++)
                yield return singleValueReader(reader);
        }
    }
    
    public class WantsToBeSerialized : IBinarySerializable
    {
        public int ID;
        public string CustomerName;
        public List<string> Nicknames;
        public SomeOtherSerializableObject Thing;
    
        void IBinarySerializable.Serialize(BinaryWriter writer)
        {
            writer.Write(ID);
            writer.Write(CustomerName);
            writer.WriteList(Nicknames, (w, value) => w.Write(value));
            writer.Write(Thing);
        }
    
        void IBinarySerializable.Deserialize(BinaryReader reader)
        {
            ID = reader.ReadInt32();
            CustomerName = reader.ReadString();
            Nicknames = new List<string>(reader.ReadList(x => x.ReadString()));
            Thing = reader.Read<SomeOtherSerializableObject>();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the

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.