From: Jan Kandziora on
Hi,

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.

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?

Kind regards

Jan


From: Uwe Klein on
Jan Kandziora wrote:
> Hi,
>
> 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.
>
> 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?
>
> Kind regards
>
> Jan
>
>

what about: "4:c3Ic10I4\0<binary string>"
( or some other arrangement that transmits the itemcount too )

another solution is to remove all length specifier elements from the
string and than count the remaining length:
c3Ic10I4
cIcI

string length cIcI
4

uwe
From: dave.joubert on
On Jul 22, 6:57 pm, Jan Kandziora <j...(a)gmx.de> wrote:
> Hi,
>
> 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.
>
> 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?
>
> Kind regards
>
>         Jan

If you still have a choice, you may want to use OSC as a protocol
instead of of rolling your own. OSC has solved all these problems and
in addition supports concepts such as bundles and arrays. Another
benefit is that that you will automatically gain access to other apps
that are not written in Tcl. I have a library somewhere that separates
the packing / unpacking from actual network transmission, and it
includes some test clients / servers.

Dave
From: Neil on
> another solution is to remove all length specifier elements from the
> string and than count the remaining length:
> c3Ic10I4
> cIcI
>
> string length cIcI
> 4
>
> uwe

Provided you also remove 'u's...
From: Uwe Klein on
Neil wrote:
>>another solution is to remove all length specifier elements from the
>>string and than count the remaining length:
>>c3Ic10I4
>>cIcI
>>
>>string length cIcI
>>4
>>
>>uwe
>
>
> Provided you also remove 'u's...

he,
I don't do newfangled options ;-)

uwe