@@ -0,0 +1,1408 @@
+import socket%0Aimport threading%0Aimport SocketServer%0A%0Aclass ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):%0A%0A    def handle(self):%0A        data = self.request.recv(1024)%0A        cur_thread = threading.current_thread()%0A        response = %22%7B%7D: %7B%7D%22.format(cur_thread.name, data)%0A        self.request.sendall(response)%0A%0A%0Aclass ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):%0A    pass%0A%0A%0Adef client(ip, port, message):%0A    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)%0A    sock.connect((ip, port))%0A    try:%0A        sock.sendall(message)%0A        response = sock.recv(1024)%0A        print %22Received: %7B%7D%22.format(response)%0A    finally:%0A        sock.close()%0A%0A%0Adef create_server(host, port):%0A    server = ThreadedTCPServer((host, port), ThreadedTCPRequestHandler)%0A    server_thread = threading.Thread(target=server.serve_forever)%0A    server_thread.daemon = True%0A    server_thread.start()%0A    print %22Server loop running in thread:%22, server_thread.name%0A    return server%0A%0Aif __name__ == %22__main__%22:%0A    HOST, PORT = %22localhost%22, 0%0A%0A    server = create_server(HOST, PORT)%0A    server2 = create_server(HOST, PORT)%0A%0A    ip, port = server.server_address%0A    ip, port2 = server2.server_address%0A%0A    client(ip, port, %22Hi world%22)%0A    client(ip, port2, %22Hullo world%22)%0A    client(ip, port, %22Sup world%22)%0A    client(ip, port2, %22Goodbye world%22)%0A%0A    server.shutdown()%0A    server2.shutdown()%0A

Add TCPServer/Client example.