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,8 +313,13 @@ class Peer:
return now - self.last_ping return now - self.last_ping
def send_packet(self, data): def send_packet(self, data):
self.srv.socket.sendto(data + StopPacket().marshal(), all_data = data + StopPacket().marshal()
0, self.addr)
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): def __str__(self):
return '%s:%d "%s" %d %d' % (self.public_ip, self.public_port, return '%s:%d "%s" %d %d' % (self.public_ip, self.public_port,