How touero/webserver works
Main Components
• Web Server Core: Represented by webserver.c, this is the central component where the server’s logic lives – from socket initialization, connection handling, to request and response processing.
• Static File Handler: The htdocs directory (which contains index.html) serves as the repository for static files. This component is responsible for serving the content to clients when a request is made.
• Build and Configuration: The Makefile shows how the server is built. You might include an element that indicates the build process and dependency management, even if it is straightforward.
Relationships and Interactions
• Listening and Accepting Connections: Start with a “Server Listener” component that sets up a socket and listens for incoming HTTP requests.
• Request Processing: When a client request is received, the server’s main loop (in webserver.c) parses the request, determines the resource requested (e.g., index.html from htdocs), and then calls the appropriate handler.
• Static Content Delivery: The server routes the request for a file to the static file handler component, retrieves the file content from htdocs, and sends it back as an HTTP response.