I'm writing a relatively simple script for receiving data via a network socket in Python. The client wants to stick with some form of start/stop signal included in the message because the sending clients will all be written in different languages, and he wants to avoid application layer assists like ZeroMQ.
I have a script which looks for start and stop signals, currently just text ("STOPSTOPSTOP" as the end of the message) but it seems klunky and prone to misinterpretation.
What might be a more ideal start and stop signal that can be attached to a socket message?
It's also been suggested using the http protocol for message passing control, but I'm not sure how to do that :-)
This is what I've come up with to date. Would love to hear suggestions for improvement.
#if you got some data, then break after wait sec
if total_data and time.time()-begin>timeout:
print "Hit timeout" #333
#if you got no data at all, wait a little longer
print "data = ", data #333
if EOT in data:
print "EOT found" #333
#check if EOT_of_data was split
if EOT in ''.join(total_data): #last_pair:
print "EOT was split" #333
final_data = ''.join(total_data)
final_data = final_data.rstrip('(0x04)')
I'd also be quite interested in learning about the features Twisted matrix offers to help with socket flow control.
Can anyone suggest a good entry point in the Twisted manual, so I don't waste a lot of time just trying to find the pertinent reading?