示例#1
0
 def start_socket(self, port, host):
     client_socket = socket.create_connection((host, port))
     
     self.must_run = True
     while self.must_run:
         
         message = SocketMessage()
         message.receive(client_socket)
             
         result_message = SocketMessage(message.call_id, message.function_id, message.call_count)
         
         if message.function_id == 0:
             self.must_run = False
         else:
             if message.function_id in self.mapping_from_tag_to_legacy_function:
                 try:
                     self.handle_message(message, result_message)
                 except Exception as ex:
                     print ex
                     result_message.set_error(ex.__str__())
             else:
                 result_message.set_error("unknown function id " + message.function_id)
         
         result_message.send(client_socket)
     
     client_socket.close()
示例#2
0
 def start_socket(self, port, host):
     client_socket = socket.create_connection((host, port))
     
     self.must_run = True
     while self.must_run:
         
         message = SocketMessage()
         message.receive(client_socket)
             
         result_message = SocketMessage(message.call_id, message.function_id, message.call_count)
         
         if message.function_id == 0:
             self.must_run = False
         else:
             if message.function_id in self.mapping_from_tag_to_legacy_function:
                 try:
                     self.handle_message(message, result_message)
                 except  BaseException as ex:
                     traceback.print_exc()
                     result_message.set_error(ex.__str__())
                     for type, attribute in self.dtype_to_message_attribute.iteritems():
                         array = getattr(result_message, attribute)
                         packed = pack_array(array, result_message.call_count, type)
                         setattr(result_message, attribute, packed)
 
             else:
                 result_message.set_error("unknown function id " + message.function_id)
         
         result_message.send(client_socket)
     
     client_socket.close()
示例#3
0
 def start_socket(self, port, host):
     client_socket = socket.create_connection((host, port))
     
     self.must_run = True
     while self.must_run:
         
         message = SocketMessage()
         message.receive(client_socket)
             
         result_message = SocketMessage(message.call_id, message.function_id, message.call_count)
         
         if message.function_id == 0:
             self.must_run = False
         else:
             if message.function_id in self.mapping_from_tag_to_legacy_function:
                 try:
                     self.handle_message(message, result_message)
                 except  BaseException as ex:
                     traceback.print_exc()
                     result_message.set_error(ex.__str__())
                     for type, attribute in self.dtype_to_message_attribute.iteritems():
                         array = getattr(result_message, attribute)
                         packed = pack_array(array, result_message.call_count, type)
                         setattr(result_message, attribute, packed)
 
             else:
                 result_message.set_error("unknown function id " + message.function_id)
         
         result_message.send(client_socket)
     
     client_socket.close()