This is an example of a very basic server code written in C. The idea of this project is to demistify the hidden components behind the most used web servers these days.
Steps to run this program:
- Make sure that a compatible C compiler is installed. I used gcc from https://gcc.gnu.org/.
- Compile using
gcc socket_example.c
- Run the compiled output using
./a.out
The following are some example requests received by this server:
- Request made via telnet:
telnet localhost 8080
- Request made via chrome browser (HTTP GET request):
http://localhost:8080
As we can see from these examples, this program is a bare minimum of a server listening for any request made to localhost on port 8080.