A set of simple web servers, all written in C, using different techniques, reflected by their names:
- serial
- fork
- pool
- select
- poll
- epoll
Static content only
These web servers do not support CGI. See the webservers-cgi project for CGI-enabled web servers.
Bugs!
Connection reset has been observed with at least the following server types:
webserver-epoll
webserver-poll
webserver-select
Build all the servers
cd serial-fork-pool-async
make all
Start a server
./webserver-<SERVER-TYPE> <port> <backlog> [<nchildren>]
Example
./webserver-epoll 12345 10
Security warning
The web server gives you read access to your entire file system, so don't make it public!
Use any client
Telnet:
telnet 0 12345
GET / HTTP/1.0
<ENTER>
<ENTER>
Browser:
Backlog
The backlog number is the maximum allowed number of pending connections.
The system wide maximum default number on a Linux machine is found in /proc/sys/net/core/somaxconn, and often defaults to 128.
Read more about backlog:
man (2) listen
How TCP backlog works in Linux
Child processes
The nchildren argument is only mandatory for webserver-pool, to specify the number of child processes.