socketserver.ThreadingTCPServer()
socketserver.ThreadingTCPServer() is a Python function in the SocketServer Module category. Creates a TCP server that handles each connection in a new thread. The syntax is socketserver.ThreadingTCPServer(server_address, RequestHandlerClass, bind_and_activate=True). Returns: ThreadingTCPServer object. A typical example: server = ThreadingTCPServer(("", 9999), Handler)
server.serve_forever() # Multi-threaded!. A close sibling is socketserver.TCPServer(), which creates a TCP server that handles connections. A close sibling is socketserver.UDPServer(), which creates a UDP server for connectionless datagrams. A close sibling is socketserver.ForkingTCPServer(), which creates a TCP server that forks a process for each connection (Unix). More about this category: Server frameworks — TCPServer, UDPServer, ThreadingTCPServer, ForkingTCPServer. Related SocketServer Module entries: socketserver.TCPServer(), socketserver.UDPServer(), socketserver.ForkingTCPServer(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try socketserver.ThreadingTCPServer() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.