Help: asyncore/asynchat and terminator string
I'm implementing a relatively simple inter-application communication
system that uses asyncore/asynchat to send messages back and forth.
The messages are prefixed by a length value and terminator string, to
signal that a message is incoming, and an integer value specifying the
size of the message, followed by the message data.
My question is: how can I produce a short terminator string that won't
show up (or has an extremely small chance of showing up) in the binary
data that I send as messages?
Frankly, I'm not so sure this is even an important question, but is
nagging me. If my communication is a kind of state machine:
sender: sends message length value, followed by terminator string,
followed by message data
receiver: waiting for terminator string via set_terminator(<terminator
continually save what comes in via collect_incoming_data()
receiver: when sender's message arrives, found_terminator() is called
pull message length from previously received data
set terminator to be the length of the message via
receiver: collect_incoming_data() collects the message data
receiver: found_terminator() called when full message length is read,
receiver goes back to waiting for message terminator string
I hope I explained that clearly enough.
The only time I can conceive that the system will get confused by
finding a terminator string in the binary data of the message is if
something goes haywire and I end up looking for a terminator string when
the other side is sending the message data. What gotchas do I need to
look out for here? I'm not a networking person, so I'm relying on the
underlying libraries to be stable and just let me handle the high-level
stuff here. This isn't going to be used in a malicious environment, the
only thing I have to contend with is network hiccups...nobody is
actively going to try and break this system.
Any advice/help would be appreciated,
|All times are GMT. The time now is 08:54 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.