Summary
We looked at how to develop network protocols while considering aspects such as the connection sequence, framing of the data on the wire, and the impact these choices will have on the architecture of the client and server programs.
We worked through different architectures for network servers and clients, demonstrating the differences between the multithreaded and event-driven models by writing a simple echo server and upgrading it to a multi-client chat server. We discussed performance issues around threaded and event-driven architectures. Finally, we looked at the eventlet
and asyncio
frameworks, which can greatly simplify the process of writing servers when using an event-driven approach.
In the next and final chapter of this book, we will look at bringing several threads of this book together for writing server-side web applications.