Skip to content

tharindra26/NoobNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 NoobNet Lighweight C Web Server

A lightweight, efficient, and extensible web server written in C. Supports static file serving, PHP execution, concurrent clients, and real-time logging.


πŸš€ Features

  • πŸ“‚ Static file serving: Supports .html, .css, .js, .jpg, .png, .mp4, .pdf, etc.
  • πŸ‘₯ Multi-client handling: Uses POSIX threads (pthread) for concurrency.
  • πŸ” HTTP/1.1 Keep-Alive: Keeps connections alive for multiple requests per client.
  • βš™οΈ PHP script execution: Handles .php files using system-installed PHP interpreter.
  • ⚑ High performance: Uses sendfile() for kernel-level, zero-copy static file delivery.
  • πŸͺ΅ Real-time logging: Logs all activity to both terminal and logs/server.log.
  • 🧾 Detailed request logs: Timestamp, log level, IP, request path, thread ID, and status.
  • ❌ Error handling: Sends 404 and 405 HTTP responses where appropriate.
  • πŸ” Path traversal protection: Blocks unsafe URL paths like ../.

πŸ“¦ Requirements

  • GCC (or compatible compiler)
  • POSIX-compliant system (Linux recommended)
  • PHP installed and available via php command

πŸ”§ How It Works

  1. Server starts on port 8080 and listens for incoming connections.
  2. Each client gets its own thread for handling requests.
  3. Request is parsed β€” only GET is supported.
  4. If file is .php, server uses popen() to execute PHP and return output.
  5. For static files, server sends file directly using sendfile() for speed.
  6. Server logs each interaction with client.

πŸ–₯️ How to Run

make
./server

🌐 Accessing the Server

Once the server is running, open your browser and go to: http://localhost:8080/

About

A simple web server using C.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published