mirror of
https://github.com/opus-tango/http-server-in-c.git
synced 2026-03-20 03:55:25 +00:00
add client handler file and code
This commit is contained in:
16
client_handler.c
Normal file
16
client_handler.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user