O'Reilly logo

Python Network Programming Cookbook by Dr. M. O. Faruque Sarker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using ForkingMixIn in your socket server applications

You have decided to write an asynchronous Python socket server application. The server will not block in processing a client request. So the server needs a mechanism to deal with each client independently.

Python 2.7 version's SocketServer class comes with two utility classes: ForkingMixIn and ThreadingMixIn. The ForkingMixin class will spawn a new process for each client request. This class is discussed in this section. The ThreadingMixIn class will be discussed in the next section. For more information, you can refer to the Python documentation at http://docs.python.org/2/library/socketserver.html.

How to do it...

Let us rewrite our echo server, previously described in Chapter 1, Sockets, IPv4, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required