Summary 93 Before we leave this example, I wanted to point out how few changes we need to make to have our example use mio as the event loop instead of the one we created. In the repository under ch04/b-epoll-mio, you'll see an example where we do the exact same thing using mio instead. It only requires importing a few types from mio instead of our own modules and making only five minor changes to our code ! Not only have you replicated what mio does, but you pretty much know how to use mio to create an event loop as well! Summary The concept of epoll, kqueue, and IOCP is pretty simple at a high level, but the devil is in the details. It's just not that easy to understand and get it working correctly. Even programmers who work on these things will often specialize in one platform (epoll/kqueue or Windows). It's rare that one person will know all the intricacies of all platforms, and you could probably write a whole book about this subject alone. If we summarize what you've learned and got firsthand experience with in this chapter, the list is quite impressive: Y ou learned a lot about how mio is designed, enabling you to go to that repository and know what to look for and how to get started on that code base much easier than before reading this chapter Y ou learned a lot about making syscalls on Linux Y ou created an epoll instance, registered events with it, and handled those events Y ou learned quite a bit about how epoll is designed and its API Y ou learned about edge-triggering and level-triggering, which are extremely low-level, but useful, concepts to have an understanding of outside the context of epoll as well Y ou made a raw HTTP request Y ou saw how non-blocking sockets behave and how error codes reported by the operating system can be a way of communicating certain conditions that you're expected to handle Y ou learned that not all I/O is equally “blocking” by looking at DNS resolution and file I/O That's pretty good for a single chapter, I think! If you dive deeper into the topics we covered here, you'll soon realize that there are gotchas and rabbit holes everywhere-especially if you expand this example to abstract over epoll, kqueue, and IOCP. Y ou'll probably end up reading Linus Torvald's emails on how edge-triggered mode was supposed to work on pipes before you know it.