def read_msg(self): """Read one message unit. It's possible however that more than one message will be set in a receive, so we will have to buffer that for the next read. EOFError will be raised on EOF. """ if self.state == 'connected': if 0 == len(self.buf): self.buf = self.inout.recv(Mtcpfns.TCP_MAX_PACKET) if 0 == (self.buf): self.state = 'disconnected' raise EOFError pass self.buf, data = Mtcpfns.unpack_msg(self.buf) return data.decode('utf-8') else: raise IOError("read_msg called in state: %s." % self.state)
def read_msg(self): """Read one message unit. It's possible however that more than one message will be set in a receive, so we will have to buffer that for the next read. EOFError will be raised on EOF. """ if self.state == 'connected': if 0 == len(self.buf): self.buf = self.inout.recv(Mtcpfns.TCP_MAX_PACKET) if 0 == (self.buf): self.state = 'disconnected' raise EOFError pass self.buf, data = Mtcpfns.unpack_msg(self.buf) return data else: raise IOError("read_msg called in state: %s." % self.state)