February 2019
Intermediate to advanced
672 pages
16h 50m
English
So, in our current example, we are able to have our asynchronous server receive, read, and process messages from clients. However, in order for our communication channel to be useful, we would also like to send messages from the server to the clients. In this section, we will update our server to an echo server, which, by definition, will send any and all data that it receives from a specific client back to the client.
To do this, we will be using the write() method from the asyncio.WriteTransport class. Examine the Chapter18/example2.py file, in the data_received() method of the EchoServerClientProtocol class, as follows:
# Chapter18/example2.pyimport asyncioclass EchoServerClientProtocol(asyncio.Protocol): ...