diff options
author | Matt Strapp <strap012@umn.edu> | 2020-12-16 06:38:12 -0600 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-12-16 06:38:12 -0600 |
commit | bdd1a19e5bddf75a79814692cef07513085bdf51 (patch) | |
tree | d3182012fdbf00c69fadee03fc0a7538099776b8 | |
parent | add temporary header print (diff) | |
download | csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.tar csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.tar.gz csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.tar.bz2 csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.tar.lz csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.tar.xz csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.tar.zst csci4061-bdd1a19e5bddf75a79814692cef07513085bdf51.zip |
finish P4
Diffstat (limited to '')
-rw-r--r-- | P4/Makefile | 2 | ||||
-rw-r--r-- | P4/README.md | 38 | ||||
-rw-r--r-- | P4/util.c | 7 |
3 files changed, 42 insertions, 5 deletions
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 @@ -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; } } |