Split packets in 4096 byte chunks

This commit is contained in:
simon.kagstrom 2009-11-07 13:50:53 +00:00
parent b919f9cf95
commit bb3fbc0fb2

View File

@ -313,9 +313,14 @@ class Peer:
return now - self.last_ping
def send_packet(self, data):
self.srv.socket.sendto(data + StopPacket().marshal(),
all_data = data + StopPacket().marshal()
for i in range(0, len(all_data), 4096):
cur = all_data[i : min(i + 4096, len(all_data))]
self.srv.socket.sendto(cur,
0, self.addr)
def __str__(self):
return '%s:%d "%s" %d %d' % (self.public_ip, self.public_port,
self.name, self.key, self.is_master)