
On 06/19/13 06:55, Michael Powell wrote:
Hello,
I need to design a delimited message framing for TCP/IP sockets, probably using Asio to facilitate transport. Then build an OSI layer 7 application vernier to handle framing.
I've dabbled a bit with Spirit and cooked up a couple of "simple" micro grammars throughout the code base. In a sense, I could see a delimited message framing strategy being a grammar of sorts, but this seems somewhat complex for a grammar to handle when you consider the overhead of verifying pass/fail (message or not a message), plus extracting the message within the delimiters.
Or, more likely approach the problem with statechart in mind. I've dealt with framed messages in the past more like this. One state is the escape byte, which can be followed by SOM, EOM, or another true-escape-byte (intended message byte). Plus other fields like message type, sub-type, how to handle payload, arguments, and so forth.
Anyone else dealt with things like this before? With Spirit? With Statechart?
Or with Lex? I would think using just the lexer would work, since, IIRC, lexers are a type of FSM, and I that's what StateChart is also. OTOH, since you have to send and receive over a network. Wouldn't karma be a candidate for composing the message just as Spirit would be a candidate for reading the message?
Regards,
Michael Powell