From: Alexandre Ferrieux on
On Jul 22, 7:57 pm, Jan Kandziora <j...(a)gmx.de> wrote:
>
> for passing arbitrary structured data through a network protocol, I'd like
> to use binary format/binary scan. My idea is to pass the format, then the
> binary blob through the channel, e.g. "c3Ic10I4\0<binary string>". No
> problem in generating this.

Side question: how useful is it for the receiver to know the exact
layout of the packet (here in four fields) and parse the fields into
separate variables if it doesn't know how to use them ? A global
length, and possibly a version identifier, should be sufficient... Am
I missing something ?

-Alex
From: Joe English on
Jan Kandziora asked:
>
> for passing arbitrary structured data through a network protocol, I'd like
> to use binary format/binary scan. My idea is to pass the format, then the
> binary blob through the channel, e.g. "c3Ic10I4\0<binary string>".
> No problem in generating this.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What are you generating this from? Do you have some other,
higher-level description of the data format from which
you're generating the format string?

> The problem is when the other side parses the format "c3Ic10I4". How to know
> in advance how many variables are needed? Is there some code snippet out
> there which does the trick?

If so, you can use the same upstream source to generate
the list of variables to assign to.


--Joe English