3
Implementing a Simple Web Server
As seen in previous chapters, we can understand that to create applications that communicate over the network, we need socket libraries. Sockets are bidirectional communication channels to send and receive data through the network. Furthermore, we also know that sockets transmit bytes, and, because of this, there is a fundamental need to implement our own communication rules (communication protocol), involving not only the order of messages but also their respective formats.
Taking this into consideration, we analyzed a well-known protocol, the HTTP protocol, and discovered that, in addition to its fame, it is relatively "simple" to implement. This is because the HTTP protocol is basically made up of a set of text messages, making them easier to understand and decode.
Therefore, the objective of this chapter is to implement a small version of a simplified web server and put all these concepts into practice. Again, we do not want to create a...