/* ############################################################################# * # DesingedWorlds * * * AUTHER: PreacherDHM * DATE: MM/DD/YY * ############################################################################# */ #include "http.h" #include #include #include #include #include #include int main() { int sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket"); return -1; } struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(9090); inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr); if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("bind"); return -1; } listen(sock, 3); printf("Server started. Listening on port 9090.\n"); while (1) { int client_sock = accept(sock, NULL, NULL); if (client_sock < 0) { perror("accept"); continue; } char* response = (char*)malloc(512); // Assuming a maximum length of 512 bytes HttpResponseHeader* header = createHttpResponse(200, HTTP_CONTENT_TYPE_HTML, "

This is a test to see what happends

", response, 512); printf("%s\n", response); printf("Sent 'Hello, World!' to the client.\n"); send(client_sock, response, strlen(response)+1, 0); } return 0; }