This project is a basic HTTP server implemented in C++, using POSIX sockets and the select() system call to handle multiple clients concurrently. It supports GET and POST requests, serves static files, and logs requests for debugging.
📅 Developed during Winter Break, December 2024 📅
🔍 Purpose: Educational project to learn about networking and server-side development in C++.
- Multi-client handling using
select() - Static file serving (
index.html,styles.css, etc.) - Dynamic responses (
/time,/echo) - Basic request logging (
logs/access.log) - Graceful shutdown (
SIGINThandling)
/http-server
│── src/
│ ├── main.cpp (Entry point, starts the server)
│ ├── server.cpp (Socket handling and select() loop)
│ ├── request.cpp (HTTP request parsing)
│ ├── response.cpp (Constructing HTTP responses)
│── public/ (Static files directory)
│ ├── index.html
│ ├── styles.css
│── logs/
│ ├── access.log
│── Makefile (For simple compilation)
│── README.md (This file)
git clone <repository-url>
cd http-servermakemake runExpected output:
🚀 Server running on http://127.0.0.1:8080
curl http://localhost:8080/index.htmlcurl http://localhost:8080/timeExpected Output:
{"time": "yourtime"}curl -X POST http://localhost:8080/echo -d "Hello, yourname!"Expected Output:
Hello, yourname!
All requests are logged in logs/access.log in this format:
[timestamp] IP:PORT METHOD PATH STATUS_CODE
Example:
[2025-03-07 15:00:00] 127.0.0.1:54321 GET /index.html 200
Press Ctrl + C to stop the server gracefully.
If you have any questions, feel free to reach out! 😊
🔗 GitHub: s1upee
🔗 Email: lisakrasiuk@gmail.com