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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:42:32+00:00 2026-05-21T03:42:32+00:00

I’m writing a server that interfaces with a proprietary protocol. Currently most of the

  • 0

I’m writing a server that interfaces with a proprietary protocol.
Currently most of the code consists of packet handlers that parse all of the fields of a packet, while making sure that the size of the data available is at least the minimum remaining size after each field. In addition to that, the packet handlers also do validity checks on the received data (i.e. must be in a certain range, or be in a set of predefined values).

Certainly this is a lot of boilerplate code when you combine it with the actual logic handling of the packet, so I would like to generate the parsers automatically and invoke the handlers on fully parsed structures.

Right now I see two approaches that I could take:

  • Come up with some metaprogramming framework that allows me to describe packet structures and eventually rules for data validation so that I can generate the parsing code at compile time. I guess this would be similar in intent to what Boost.Spirit does.

  • Write my own data description language and an external tool that will generate C++ code from it. Doesn’t seem too hard but would certainly clutter up the build process and I generally dislike using large amounts of tool-generated code. Also this wouldn’t permit quickly changing data descriptions inside the source code itself.

The metaprogramming way seems superior in theory, but I haven’t thought out a flawless way of implementing this yet. Preferably declaring packets would be similar to declaring a class and would not be full of macros. There’s also a problem in cases where I have to refer to previous data members (which is the case for fields repeated a variable number of times, where the count is specified earlier in the packet).

Does anyone have experience with similar frameworks, and what would you suggest?

I know about Google Protocol Buffers but that is intrusive in that it requires being in control of the protocol.

  • 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-21T03:42:33+00:00Added an answer on May 21, 2026 at 3:42 am

    I’ve gone the route of creating my own language and tooling for binary structured data multiple times in the past, but that was in part driven by the need to support multiple target languages from the data definitions (at the time, C# and C++); I also created a third target to produce HTML reference documentation from the definitions.

    The main advantage I can see in using C++ template metaprogramming is that you can directly interact with the compile-time type system if and when that is useful. For typical binary structured data, though, I’ve never found it to be all that useful. For example, you’d need a way to process the relevant members in a specific order; Boost serialization does that by requiring a serialization method that specifies which members are processed and in what order.

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

Sidebar

Related Questions

No related questions found

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.