server05 start

This commit is contained in:
2025-07-30 22:03:28 +01:00
parent a72cceca00
commit 63d237226f
3 changed files with 41 additions and 1 deletions

26
server05.c Normal file
View File

@@ -0,0 +1,26 @@
//
// Created by Ajurna on 30/07/2025.
//
#include "server05.h"
#include <pthread.h>
#include <winsock2.h>
#include <stdio.h>
#include "data.h"
int main() {
SOCKET server = get_listen_socket();
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));
args->client = client;
args->connection = connection_number++;
pthread_t thread;
pthread_create(&thread, nullptr, handle_connection, args);
}
return 0;
}