Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Help: asyncore/asynchat and terminator string (http://www.velocityreviews.com/forums/t398297-help-asyncore-asynchat-and-terminator-string.html)

David Hirschfield 01-16-2007 11:05 PM

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
string>)
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,
-Dave

--
Presenting:
mediocre nebula.



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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57