Added log for incoming connections and fixed memory cleanup in server01.c.

This commit is contained in:
2025-07-28 20:22:26 +01:00
parent d4ea1c9213
commit 84339df5fa

View File

@@ -19,10 +19,11 @@
#define IS_PRIME_ERROR "{\"method\":\"isPrime\",\"error\":true}\n"
int main() {
SOCKET server = get_listen_socket();
SOCKADDR_IN serverAddr, clientAddr;
SOCKADDR_IN clientAddr;
SOCKET client;
int clientAddrSize = sizeof(clientAddr);
int connection_number = 1;
printf("Listening for incoming connections...\n");
while((client = accept(server, (SOCKADDR *)&clientAddr, &clientAddrSize)) != INVALID_SOCKET)
{
handle_args_t *args = malloc(sizeof(handle_args_t));
@@ -46,11 +47,9 @@ void *handle_connection(void *args) {
while ((request = char_array_get_until_char(data, '\n')) != NULL) {
parse_request(handleArgs, request, data);
}
memset(buffer, 0, sizeof(buffer));
}
free(handleArgs);
pthread_exit(NULL);
}