Skip to content
Sumedh

A tiny HTTP web server in C

Download httpwebserver.zip

  • A basic web server written in C, uses threads instead of fork hence takes very few resources.
  • Displays 404 error if a page is not found.
  • Server displays the client's ip address and the path of the page requested.

Usage

  • Compile the program with the -lpthread parameter.
      gcc -lpthread httpwebserver.c
  • After compiling run the program with port number as the parameter.
      ./a.out 3000 (you can enter any free port number)
  • Open your web browser and enter "127.0.0.1:xyz" (without the quotes) where xyz is the port number you entered, in the address bar. The index.htm page will load.
  • You will have to change the path of the default webpage. It depends on where you store the code file and the 'index.htm' page.
  • To shutdown the server press Ctrl + C

System Requirements

  • Linux
  • Gcc