Hypertext Transfer Protocol and web server.
- This project is to implement a simple HTTP server in C++ 98
- The server operates using IO multiplexing.
- The execution environment is designed for Mac(Kqueue) and may not be supported on other platforms.
- Most of the operations have been implemented based on Nginx.
-
The program operates with two loops: one loop fetches events from the kernel, and the other loop processes these events.
In case an exception occurs during the event processing, it is caught and a response message is composed to be sent to the client. -
The configuration file contains rules that the server can use to process requests. These rules are parsed according to predefined classes.
-
Once parsing is complete, sockets are created and set to listen based on the parsed server information.
Below is an illustration of the program's socket communication method: -
Kqueue is a function that supports IO multiplexing.
Through Kqueue, you can receive events to send or receive data to/from the buffers of file descriptors. -
Events are branched and processed according to their respective conditions.
-
Since the program must continuously process events, it handles all file descriptors (FDs) in a non-blocking, asynchronous manner. Therefore, because the order of operations is not guaranteed, it assigns state values to each object to facilitate performing actions based on their respective states.
Rules | Description |
---|---|
all | Compile a program webserv. |
clean | Remove all the temporary generated files. |
fclean | Remove all the generated files. |
re | Remove all the generated files and compile a webserv. |
Run the configuration file as an argument.
$> ./webserv [configuration file]
Doesn't necessarily require an argument.
$> ./webserv
In this case, the file in the default path(conf/defualt.conf) is configured.