From bdd1a19e5bddf75a79814692cef07513085bdf51 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 16 Dec 2020 06:38:12 -0600 Subject: finish P4 --- P4/Makefile | 2 +- P4/README.md | 38 ++++++++++++++++++++++++++++++++++++++ P4/util.c | 7 +++---- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 P4/README.md diff --git a/P4/Makefile b/P4/Makefile index 2829f78..c404375 100644 --- a/P4/Makefile +++ b/P4/Makefile @@ -3,7 +3,7 @@ CFLAGS = -D_REENTRANT LDFLAGS = -lpthread -pthread web_server: server.c util.c - ${CC} -Wall -o web_server server.c util.c ${LDFLAGS} + ${CC} -Wall -g -o web_server server.c util.c ${LDFLAGS} clean: rm web_server webserver_log diff --git a/P4/README.md b/P4/README.md new file mode 100644 index 0000000..163e439 --- /dev/null +++ b/P4/README.md @@ -0,0 +1,38 @@ +# CSCI 4061: Project 4 + +The fourth project in CSCI 4061: Intro to Operating Systems. + +## Fall 2020 + +- **Test machine:** atlas.cselabs.umn.edu +- **Date:** 12/10/2020 +- **Name:** Andrea Smith, Matt Strapp +- **x500:** smit9523, strap012 + +The purpose of this program is to create a multi-threaded web server by using POSIX threads. In this project, we wrote the backend using POSIX sockets. + +In order to run this program, compile with the included makefile (run ```make``` in the directory with no additional arguments). After that, run ```./web_server``` with the following additional arguments seperated by only a space (with no quotes or brackets): +[Port used (between 1025 and 65535)] [Web server directory] [Number of dispatch threads] [Number of worker threads] [Maximum worker queue length] [NOT IMPLEMENTED (Use 0)] [Maximum cache length] + + +#### Program structure + +```init():``` +Binds a port that the server can use to communicate with the outside world. + +```accept_connection():``` +Makes a one-time use socket for the connection. + +```get_request()``` +Takes the HTTP request and translates it to a file path that the server can use. + +```return_result()``` +Formats the return to the HTTP protocol and returns the successful request back to the client. + +```return_error()``` +Formats the return to the HTTP protocol and returns the unsuccessful request back to the client. + + +#### Team Contributions: + +Matt wrote init(), return_result(), and return_error(). Andrea wrote accept_connection() and get_request(). \ No newline at end of file diff --git a/P4/util.c b/P4/util.c index 07a18ef..652ba95 100644 --- a/P4/util.c +++ b/P4/util.c @@ -118,8 +118,7 @@ int get_request(int fd, char *filename) { } return -1; } - //Print header - printf("%s %s %s\n", get, filename, http); + if (strcmp(get, "GET")) { if (close(fd) == -1) { perror("Socket close error"); @@ -133,7 +132,7 @@ int get_request(int fd, char *filename) { perror("Socket close error"); return -15; } - printf("Not sure but bad\n"); + printf("Filename too long\n"); return -3; } //--END ERROR HANDLING-- @@ -143,7 +142,7 @@ int get_request(int fd, char *filename) { perror("Socket close error"); return -15; } - printf("Invalid directory!\n"); + printf("Invalid directory format\n"); return -4; } } -- cgit v1.2.3