You're missing "self." in several places..
On 6/27/07, steven wang
class MyProtocol(protocol.Protocol):
is_big_data = False big_data = '' big_data_size = 0
def connectionMade(self): self.big_data = '' self.big_data_size = 0 self.is_big_data = False pass
def dataReceived(self, data):
if check_head_ok(data): should be self.check_head_ok(data)
# To receive the big size data if self.is_big_data: return
# The big data will overflow the Twisted receive buffer size, so loop to receive data if is_big_size_data:
self.is_big_size_data
big_data += data
self.big_data
if big_data_size == len(big_data):
self.big_data_size == len(self.big_data)
# To save data to database .... pass
def connectionLost(self, reason): self.big_data = '' self.big_data_size = 0 self.is_big_data = False pass
def check_head_ok(self, head): if data.startswith('ABC'): values = data.split(',') self.big_data_size = int(values[1]) self.is_big_data = self.big_data_size > 0 return True else: return False ================================================================================================
The check_head_ok also won't work like that. First off you need to change head to values there - and since dataReceived is called multiple times, you need to make sure check_head_ok is only called at the beginning. Arnar