コード例 #1
0
 def client_send(self, dest, msg):
     #print msg.service, msg.type, str(dest)
     HOST = dest.IPAddr
     PORT = dest.ctrlPort
     DATA = msg.serialize()
     ##print len(DATA)
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.settimeout(2.0)
     try:
         # Connect to server and send data
         sock.connect((HOST, PORT))
         sock.send(DATA)
         sock.shutdown(1)
         ack = sock.recv(1)
     except socket.error:
         ##print e
         #sock.close()
         print "SOCKET ERROR", "Tried to send to ", HOST, ":",PORT
         node.message_failed(msg,dest)
         #self.update_messages_in_queue(dest)
     finally:
         #print ">",
         sock.close()
         ##print DATA[-20:],len(DATA)%8
         return True
コード例 #2
0
 def client_send(self, dest, msg):
     #print msg.service, msg.type, str(dest)
     HOST = dest.IPAddr
     PORT = dest.ctrlPort
     DATA = msg.serialize()
     ##print len(DATA)
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.settimeout(2.0)
     try:
         # Connect to server and send data
         sock.connect((HOST, PORT))
         sock.send(DATA)
         sock.shutdown(1)
         ack = sock.recv(1)
     except socket.error:
         ##print e
         #sock.close()
         print "SOCKET ERROR", "Tried to send to ", HOST, ":", PORT
         node.message_failed(msg, dest)
         #self.update_messages_in_queue(dest)
     finally:
         #print ">",
         sock.close()
         ##print DATA[-20:],len(DATA)%8
         return True
コード例 #3
0
 def update_messages_in_queue(self, failed_node):
     hold = []
     while not self.tosend.empty():
         temp = self.tosend.get()
         self.tosend.task_done()
         if temp[1] == failed_node:
             node.message_failed(temp[2],temp[1])
         else:
             hold.append(temp)
     for h in hold:
         self.tosend.put()
コード例 #4
0
 def update_messages_in_queue(self, failed_node):
     hold = []
     while not self.tosend.empty():
         temp = self.tosend.get()
         self.tosend.task_done()
         if temp[1] == failed_node:
             node.message_failed(temp[2], temp[1])
         else:
             hold.append(temp)
     for h in hold:
         self.tosend.put()