r/cprogramming • • 2d ago

HTTP Server In C

I just watched a yt video on low-level

Context: lately I have been learning the basics of how CPUs work, and since I like programming, I want to work on a project that will force me to learn the computer I am working with

my question is what do i need to know in C before I can start this project, I learnt C in the past before i just never built anything, my programming background is in python

Link to the YouTube video: https://youtu.be/97i2BAUw5Xc?si=aoAhmeGOKc6su5M_

11 Upvotes

12 comments sorted by

3

u/alkavan 2d ago

I would suggest, before building an HTTP server, build a sockets server and client first: Beej's Guide to Network Programming is a great starting point, of course http server uses sockets so you can upgrade it later.

The nghttp2 project is great example how to build your http server.

Other than that, learning a programming language without using it a lot, is like not learning it at all. In programming there's a huge difference between theory and practice, but especially so in C.

1

u/codingking329 7h ago

I am reading Beej's Guide to Network Programming, and im on chapter two ( first page) is it normal, I have so many questions while reading :( , my previous knowledge on C is what holding me afloat, I have't even got to the part where i get to write an actual program

1

u/alkavan 5h ago edited 5h ago

It's a guide, not a beginner tutorial, and network/socket programming is not as easy as building other stuff in C (it involved async io that is not an easy concept). Maybe, before getting into networking, you might want to build some other stuff, that could be more satisfying. Small, scoped wins are important when learning C.

I can suggest looking into a graphics library like SDL3, that has it's own SDL3_net component to build network stuff. Seeing the stuff you build on the screen might give you more motivation than building something that happens on a lower level of the operating system and requires "sniffing" to "see" like the network stack. The most important thing is getting comfortable with the C language, and my advice is not giving up on that, it would provide you a strong base knowledge for the rest of your career if you would choose so.

I think many people are mistaken by trying to build stuff from scratch when learning C, obviously, they would fail many times and that can be very frustrating. It's much better to look into well known C libraries and application that already exist for two or three decades, and already figured out how to do stuff in C.

1

u/Interesting-Speed449 5h ago

Im actually a first year CS student ( ik you didn’t ask) im currently on chapter 3, so far we talk about data encapsulation, TCP and UDP
That what point do I start programm or know enough to start.. I don’t want to give up yet I love the book his writing style is great 😭

2

u/ChickenSpaceProgram 2d ago

learn as you go; reference a manual or book as you try to build whatever you want to build when you get stuck.

2

u/71d1 2d ago

Depends on what you want this HTTP server to do, if you just want to serve a single file to a single connection, all you will want is to learn network programming. If you want to learn how to make a production HTTP server you'll need to learn RFC 2616, RFC 3875, Network programming, threads, mutexes, and conditional variables.

2

u/dariusbiggs 2d ago

You will need to get comfortable reading the RFC specifications and yow to understand them.

You will nees to learn about parsing text safely

You may need to learn about finite state automata

You will need to learn how to safely use memory

You should learn about defensive programming, trust nothing, verify and validate everything. This is the only one you should read up on before you start.

You should learn about writing tests, unit tests, and integration tests.

All of these can be learned as you go, and they are valuable learning experiences if you get them wrong.

2

u/zhivago 1d ago

http 0.9 is extremely simple.

Just learn about sockets.

1

u/Electrical_Hat_680 22h ago

Learn how to create the sockets in binary and assembly. Open(); Close();.

0

u/[deleted] 2d ago

[removed] — view removed comment

1

u/AdOnly69 2d ago

Please, don't watch (or at least take seriously) "Low Level" (author of the video you linked), he is a content maker, not a real programmer