:\pp \internet\socketspython echo-client py localhost bright side of life client receivedb"echo=> 'brightat sun apr : : client receivedb"echo=> 'sideat sun apr : : client receivedb"echo=> 'ofat sun apr : : client receivedb"echo=> 'lifeat sun apr : : remember that thread silently exits when the function it is running returnsunlike the process fork versionwe don' call anything like os _exit in the client handler function (and we shouldn' --it may kill all threads in the processincluding the main loop watching for new connections!because of thisthe thread version is not only more portablebut also simpler standard library server classes now that 've shown you how to write forking and threading servers to process clients without blocking incoming requestsi should also tell you that there are standard tools in the python standard library to make this process even easier in particularthe socketserver module defines classes that implement all flavors of forking and threading servers that you are likely to be interested in like the manually-coded servers we've just studiedthis module' primary classes implement servers which process clients in parallel ( asynchronouslyto avoid denying service to new requests during long-running transactions their net effect is to automate the top-levels of common server code to use this modulesimply create the desired kind of imported server objectpassing in handler object with callback method of your ownas demonstrated in the threaded tcp server of example - example - pp \internet\sockets\class-server py ""server sideopen socket on portlisten for message from clientand send an echo replythis version uses the standard library module socketserver to do its worksocketserver provides tcpserverthreadingtcpserverforkingtcpserverudp variants of theseand moreand routes each client connect request to new instance of passed-in request handler object' handle methodsocketserver also supports unix domain socketsbut only on unixensee the python library manual ""import socketservertime myhost 'myport def now()return time ctime(time time()get socket serverhandler objects server machine'means local host listen on non-reserved port number class myclienthandler(socketserver baserequesthandler)def handle(self)on each client connect print(self client_addressnow()show this client' address time sleep( simulate blocking activity while trueself request is client socket network scripting