I use UDPServer based on BaseServer to receive frag UDP packets .
But some packets are larger than 8192 bytes(@handle method, print len(data)), and I can't use them correctly.
My original code:
class MyUDPHandler(SocketServer.BaseRequestHandler):
def handle(self):
global arr_len_recv
data = self.request[0].strip()
socket = self.request[1]
s_recv_paylaod_len = len(data)
print "s_paylaod",binascii.hexlify(data)
if __name__ == '__main__':
server = SocketServer.UDPServer((HOST, LISTEN_PORT), MyUDPHandler)
tmp = threading.Thread(None, loop_send, None,(param,server) , {})
tmp.daemon=True
tmp.start()
poll=0.1
server.serve_forever(poll)
So I RTFM BaseServer,UDPServer,TCPServer.
python SocketServer documentation
I found in SocketServer.TCPServer Example
class MyTCPHandler(SocketServer.BaseRequestHandler):
def handle(self):
self.data = self.request.recv(1024).strip()
But self.request doesn't have recv method
If you have any solution to fix it or to change max limit of recv buffer.
Finally, I found it in baseserver python source code :
480 class UDPServer(TCPServer):
481
482 """UDP server class."""
483
484 allow_reuse_address = False
485
486 socket_type = socket.SOCK_DGRAM
487
488 max_packet_size = 8192
My modified main (see server.max_packet_size )
if __name__ == '__main__':
server = SocketServer.UDPServer((HOST, LISTEN_PORT), MyUDPHandler)
server.max_packet_size = 8192*2
server.serve_forever()