> What I really want is a dead simple framing protocol that simply
> prefixes the message with a 16-bit number (or 32-bit number) that
> indicates the number of bytes that follow. I'm new to Python so I'm
> not quite sure how to go about this though. I wrote a proof-of-concept
> by using struct.pack(), but I'm not sure how to calculate the message
> length properly. E.g. if the message type is a unicode string len()
> will give me number of characters rather than the length of the string
> in bytes, correct?
>
> So any pointers before I go and implement my framing component properly?

I think you're right - I'm pretty sure we don't have any components
that provide quite what you're after. But they don't sound too
difficult to write.

Regarding the unicode issue - I'm not 100% sure, but I think this only
becomes a problem in python 3.x. For better or worse (worse probably!)
many existing Kamaelia components represent binary data as strings,
and I think most of them use len() to determine the number of bytes
contained in them.

With your mention of bits, do I take it you're after conveying binary,
rather than textual payloads? (eg. payloads that might contain byte
values equivalent to characters such as newline)
Would I also be right in guessing that you intend to pass these
messages across a TCP connection, rather than as UDP packets? If
either of these is the case, then the Framer and DeFramer components
you spotted won't be up to the job, even if you did add dummy tag
values.

That said, I think it is perfectly reasonable to use the DataChunker
and DataDeChunker components in the manner you describe - by sending a
sync sequence immediately after a message to flush it through the
dechunker. The other thing to consider is that you wouldn't actually
need to frame the payload by prefixing it with its size - since the
sync bytes delimit it. Probably would need a few extra components
writing to achieve this though (or the creation of modified versions
of DataChunker and DataDeChunker)


Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"kamaelia" group.
To post to this group, send email to kamaelia@googlegroups.com
To unsubscribe from this group, send email to 
kamaelia+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to