Hi,
I need some hints on how to code persistent HTTP connection using C socket programming.
I have studied mini-httpd and thttpd, but realize that perhaps they didn't implement this feature. I have analysed the packets exchanged between a HTTP client and mini-httpd server using ethereal.
The client initiates a request by first sending HTTP HEAD. Upon receiving, the mini-httpd sends HTTP response 200 OK and subsequently close connection. The client is supposed to send HTTP GET, but upon closing of connection, the entire HTTP transaction stop.
thttp has the same output. It seems that mini-httpd/thttp do not support persistent HTTP connection, which allow multiple request and response in one TCP connection establishment.
I have tested with mini-httpd by commenting out close(conn_fd) in main(), it turns out that the server does not initiate connection close, and the client is able to send a HTTP GET. But upon receiving HTTP GET request, mini-httpd shows errno=ENOSOCK in the main loop, and the server does not fork a new sub-process to handle HTTP GET request. So the client RST at timeout and stop.
As there is no way to change the implementation of HTTP client, I am seeking possibility to change mini-httpd/thttpd to support persistent connection. Does anybody has already enhance this feature in mini-httpd/thttpd? or perhaps some hints on how to code is truely appreciated.
Or is there any existing open source small HTTP web server that implement persistent HTTP connection? Apache is just too huge and complex. BTW, some hints on apache's code on implementing persistent HTTP is also appreciated.
Thank you.