O'Reilly logo

Python Network Programming Cookbook - Second Edition by Dr. M. O. Faruque Sarker, Pradeeban Kathiravelu

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

How to do it...

We need to write an efficient chat server that can handle several hundred or a large number of client connections. We will use the select() method from the select module that will enable our chat server and client to do any task without blocking a send or receive a call all the time.

Let us design this recipe such that a single script can launch both client and server with an additional --name argument. Only if --name=server is passed from the command line, the script will launch the chat server. Any other value passed to the --name argument, for example, client1, client2, will launch a chat client. Let's specify our chat server port number from the command line using the --port argument. For a larger application, it may be ...

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