add client handler file and code

This commit is contained in:
Nayan
2025-05-05 20:49:27 -04:00
parent 8efb833cca
commit 8473615df5
4 changed files with 39 additions and 5 deletions

16
client_handler.c Normal file
View File

@@ -0,0 +1,16 @@
#include "client_handler.h"
#define BUFFER_SIZE 1024
void* client_handler(void* args) {
int client = *((int*)args);
char* buffer = (char*)malloc(BUFFER_SIZE);
ssize_t bytes_read = recv(client, buffer, BUFFER_SIZE, 0);
if (bytes_read > 0) {
buffer[bytes_read] = '\0';
printf("Received: %s\n", buffer);
}
free(buffer);
return NULL;
}