Python Network Programming
by Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
How it works...
Our script has taken a command-line argument for --port and passed this to the main() function where our Diesel application has been initialized and run.
Diesel has a notion of service where an application can be built with many services. EchoServer has a handler() method. This enables the server to deal with individual client connections. The Service() method takes the handler method and a port number to run that service.
Inside the handler() method, we determine the behavior of the server. In this case, the server is simply returning the message text.
If we compare this code with Chapter 11, Sockets, IPv4, and Simple Client/Server Programming, in the Writing a simple echo client/server application recipe (listing 1.13a
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access