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 1, Sockets, IPv4, and Simple Client/Server Programming, in the Writing a simple echo client/server application recipe (listing 1.13a), it is very clear that we do not need to write any boiler-plate code and hence it's very easy to concentrate on high-level application logic.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.18.218