Back to Projects

HTTP-Server-In-C

C winsock2

Project Overview

A simple and lightweight HTTP server in C using Winsock2

If you are wondering why winsock2:

During my search for how to write an HTTP server in C, I started reading the socket(7) - Linux man page since building for UNIX is the default in most guides/tutorials. I quickly realized this API won’t work on my Windows machine, so I went to the Windows Official API reference to cross reference the functions I need to create the server and test it.

Features

Sending & Receiving HTTP requests

What I Learned

Creating this project taught me the fundamentals of how HTTP servers function and how they are built on top of TCP sockets, I learned:

  • TCP socket creation
  • Binding to a port
  • Listening for incoming connections
  • Accepting client connections
  • Receiving HTTP requests
  • Sending HTTP responses