How it works...

In our EpollServer web server's constructor, a socket server is created and bound to a localhost at a given port. The server's socket is set to the non-blocking mode (setblocking(0)). The TCP_NODELAY option is also set so that our server can exchange data without buffering (as in the case of an SSH connection). Next, the select.epoll() instance is created and the socket's file descriptor is passed to that instance to help monitoring.

In the run() method of the web server, it starts receiving the socket events. These events are denoted as follows:

  • EPOLLIN: This socket reads events
  • EPOLLOUT: This socket writes events

In the case of a server socket, it sets up the response SERVER_RESPONSE. When the socket has any connection that wants to write data, it can do that inside the EPOLLOUT event case. The EPOLLHUP event signals an unexpected close to a socket that is due to the internal error conditions.

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

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