From 417ad87628bc11fcd42294920624af700c516b7a Mon Sep 17 00:00:00 2001 From: Nayan <33187059+GShadow5@users.noreply.github.com> Date: Mon, 5 May 2025 20:36:02 -0400 Subject: [PATCH] accept connections --- webserver.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/webserver.c b/webserver.c index 3a686c9..f9b2a8c 100644 --- a/webserver.c +++ b/webserver.c @@ -33,4 +33,18 @@ int main(int argc, char **argv) { perror("listen failed"); exit(1); } + + while (1) { + struct sockaddr_in client_addr; + socklen_t client_len = sizeof(client_addr); + int *client = malloc(sizeof(int)); + + *client = accept(server, (struct sockaddr *)&client_addr, &client_len); + if (client < 0) { + perror("Failed to accept client"); + continue; + } else { + printf("Client connected\n"); + } + } } \ No newline at end of file