Exemplo n.º 1
0
    def handle(self):

        # Try to get the message length (2 bytes)

        len_buf = self.read(self.request, 2)
        msg_len = struct.unpack("!H", len_buf)[0]

        data = self.read(self.request, msg_len).strip()
        m = TCPMessage()
        m.decode(data)
        print m
Exemplo n.º 2
0
        def handle(self):
            global shutdown_flag
            while not shutdown_flag:
                len_buf = self.read(self.request, 2)
                msg_len = struct.unpack("!H", len_buf)[0]

                data = self.read(self.request, msg_len).strip()
                m = TCPMessage()
                if m.decode(data):
                    # TODO: Is infinite blocking the best behavior?
                    global_sim_queue.put(m, block=True, timeout=None)