By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,660 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

Help: asyncore/asynchat and terminator string

P: n/a
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
set_terminator(<message length>)
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,

mediocre nebula.

Jan 16 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.