views:

115

answers:

3
+1  A: 

I'd recommend grabbing the source for Apache and seeing how they handle it. There's not much point in psuedo code when you can see how the real thing works.

James Branigan
Great minds think alike? ;)
alex
our answers must have passed in the tubes :)
James Branigan
+1  A: 

Perhaps you could look at Apache's code for some clues. It is written in C.

Hopefully someone will come along and give a more detailed answer :)

alex
I am trying to avoid doing this as much as possible. I started to the other day, but filtering things that I don't need to know at the moment from things I need to are very time consuming.
+1  A: 

I would recommend looking at GNU libmicrohttpd. It focuses squarely on providing a framework upon which to build HTTP 1.1 servers. It is small and supports keep-alive with and without threading. (Personally I use it without threading. It has several threading models too.)

Even if you decide to write your web server from scratch, I would suggest looking at libmicrohttpd to gain insight in not only how the protocol works, but how the library models "the work flow" of a web server in a very clean way. I think it is a mistake to imagine that keep-alive implies threading and I think it is an impediment to understand keep-alive.

(Regarding Apaches' credits as web server, it is pretty huge, and there is a lot in there not related to protocols, but rather things like its plugin system and so on.)

Amigable Clark Kant
Thanks, i'll look into that after I get out of work today.