resume TCP comunication

Z

zunbeltz

Hi,

I'am writing a program to cotrol a machine. I use socket comunication
(TCP) to do it.
I do a measurement in my machine like this:

def DoMeasurement():
setup1()
setup2()
while MeasurementNotFinished():
move()
measure()
finalizeMeasurement()


Each funciton setup1, setup2, move,mesure, ... call a method in a class
that contains a socket that do the comunication staff

class DiSock(socekt):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def comunicate(self):
self.sock.sendall(Request.struct2string())

msg = ''
MSGLEN = 608
while len(msg) < MSGLEN:
chunk = self.sock.recv(MSGLEN-len(msg))
if chunk == '':
raise RuntimeError,"socket connection broken"
msg = msg + chunk
data = msg
Answer.string2struct(data)


Request and Anser are objects in where i put the information i whant to
send and recive from the
machine.

All the measurement is done in a new thread.

The problem is that sometimes i loose the conenction whith the
machines. In the case a ConnectionFailure exception is raised. How can
i do resume the Measurement when the conection is resumed? Can i use a
yield for this?

Thanks in advance

Zunbeltz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top