I have learned before TCPServer The use of the class , If you haven't learned , Go back and look at it first , Otherwise you won't understand the knowledge here . Create a server object UDPServer after , call serve_forever Function to start a loop event , Can continuously receive requests from clients , Until it's closed . There is also a need to inherit BaseRequestHandler class , heavy load handle Method , Only in this way can we receive UDP The message sent by the client , At the same time respond to the client . Be careful here self.request, It has two members ,self.request[0] Is said UDP The message sent by the client ,self.request[1] Is said socket object , You can send messages to clients through this object .