r/C_Programming • • 28d ago

Suggest me sources for http server

I want to make http server in C/C++ but I can't find the exact source that will teach me the basics of networking and give code snippets I've checked beejs guide but one is totally theory a new other is totally programming

So anyone please suggest me a source to learn about networking (to the point ) Docs or video anything can be accepted Thanks for you time!

18 Upvotes

16 comments sorted by

14

u/vectorj 28d ago

1

u/Realistic_Debate1704 28d ago

Thanks, I tried it.

3

u/gremolata 28d ago

Sounds ominous ...

1

u/Realistic_Debate1704 27d ago

Nooo, but sorry if it did

2

u/LordRybec 28d ago

Beej has an interprocess communcations (IPC) guide that goes over sockets, with code examples. I used it as a textbook for an undergrad IPC course I taught, and it does a pretty good job of balancing theory with practical examples.

That said, I wouldn't expect to find a full tutorial. I haven't even been able to find good tutorials on implementing IRC protocol in any language I care to do it in, and that's much simpler than HTTP. You'll likely need to put together a selection of different resources and draw what you need from each one.

8

u/SeriousPlankton2000 28d ago

The most simple server is listening on port 80, reading till there are two "\n" and then writing the headers, an extra "\n" and the content of the page.

Here is the documentation on what to do on the protocol layer:

https://www.rfc-editor.org/rfc/rfc9110.html

3

u/Realistic_Debate1704 28d ago

Thanks man 😍

3

u/LordRybec 28d ago

Yeah, the networking is pretty easy, despite being a little bit of a pain in C. Parsing text, including headers, and especially variable length headers, is a huge pain in C. That will be the hard part! (Well, not the only one, but the first one.)

3

u/Evil-Twin-Skippy 28d ago

https://fossil.etoyoc.com/fossil/clay/index

I'm the developer for the httpd module in Tcllib. If you think of Tcl as "The C Library", having the stack in script solves a whole bunch of problems.

3

u/Realistic_Debate1704 28d ago

Wow, nice sir, I'm glad that you helped, thank you

5

u/[deleted] 28d ago

[removed] — view removed comment