This commit is contained in:
2025-12-02 18:48:52 +00:00
parent eb0cce53f7
commit 98afbb60e9
4 changed files with 121 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:noble"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
+7 -7
View File
@@ -1,7 +1,7 @@
## cos440-fp ##
[![](https://gitea-actions.nicholaspease.com/actions/umaine-npease/cos440-fp/badge?label=build&style=flat&branch=main)](https://gitea-actions.nicholaspease.com/latest-log?branch=main)
[![](https://drone.nicholaspease.com/api/badges/umaine-npease/cos440-fp/status.svg)](https://drone.nicholaspease.com/umaine-npease/cos440-fp)
[![](https://wakaapi.nicholaspease.com/api/badge/LAX18/interval:any/project:cos440-fp)](https://wakaapi.nicholaspease.com/summary?interval=any&project=cos440-fp)
![](https://server1.nicholaspease.com/badges/cloc/npease/cos440-fp.svg)
<hr>
## cos440-fp ##
[![](https://gitea-actions.nicholaspease.com/actions/umaine-npease/cos440-fp/badge?label=build&style=flat&branch=main)](https://gitea-actions.nicholaspease.com/latest-log?branch=main)
[![](https://drone.nicholaspease.com/api/badges/umaine-npease/cos440-fp/status.svg)](https://drone.nicholaspease.com/umaine-npease/cos440-fp)
[![](https://wakaapi.nicholaspease.com/api/badge/LAX18/interval:any/project:cos440-fp)](https://wakaapi.nicholaspease.com/summary?interval=any&project=cos440-fp)
![](https://server1.nicholaspease.com/badges/cloc/npease/cos440-fp.svg)
<hr>
BIN
View File
Binary file not shown.
+92
View File
@@ -0,0 +1,92 @@
/*
Final Project - Part 1
Nicholas Pease
COS440
*/
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
// Constants
#define PORT 5000
#define DEBUG 0
// Globals
// Structs
struct http_start_line {
char method[8];
char path[1024];
char version[16];
};
struct http_header {
char field_name[256];
char field_value[1024];
};
struct http_message {
struct http_start_line start_line;
struct http_header headers[100];
char body[8192];
};
// Functions
struct http_message create_http_message_from_string(char *message_str) {
struct http_message message;
}
// Main
int main(int argc, char *argv[]) {
// Setup TCP Socket
if (DEBUG) printf("SETUP: Setup Sockets\n");
int serv_sock, client_sock, read_size;
struct sockaddr_in server, client;
char client_message[20000];
serv_sock = socket(AF_INET, SOCK_STREAM, 0);
client_sock = socket(AF_INET, SOCK_STREAM, 0);
if (DEBUG) printf("SETUP: Socket Created\n");
// Bind Sockets
server.sin_family = AF_INET;
server.sin_port = htons(PORT);
// inet_pton(AF_INET, INADDR_ANY, &(server.sin_addr));
bind(serv_sock,(struct sockaddr *)&server, sizeof(server));
if (DEBUG) printf("SETUP: Socket Bound\n");
// Start Listening and Waiting for Connections
listen(serv_sock, 1);
if (DEBUG) printf("SETUP: Listening for Connections\n\n");
while (1) {
// Accept Connection from Client
if (DEBUG) printf("WAIT: Waiting for incoming connections...\n");
int c = sizeof(struct sockaddr_in);
client_sock = accept(serv_sock, (struct sockaddr *)&client, &c);
if (DEBUG) printf("CONNECT: Connection Accepted\n");
// Receive Message from Client
memset(client_message, 0, sizeof(client_message));
read_size = recv(client_sock, client_message, sizeof(client_message), 0);
if (DEBUG) printf("RECEIVE: Message Received\n");
// Process Message From Client
if (DEBUG) printf("PROCESS: Processing Message\n");
struct http_message message = create_http_message_from_string(client_message);
// Close Client Socket
close(client_sock);
if (DEBUG) printf("DISCONNECT: Client Disconnected\n\n");
}
return 0;
}