server05 start
This commit is contained in:
@@ -31,4 +31,6 @@ add_executable(server03 server03.c server03.h ${COMMON_SOURCES})
|
|||||||
target_link_libraries(server03 wsock32 ws2_32)
|
target_link_libraries(server03 wsock32 ws2_32)
|
||||||
|
|
||||||
add_executable(server04 server04.c server04.h ${COMMON_SOURCES})
|
add_executable(server04 server04.c server04.h ${COMMON_SOURCES})
|
||||||
target_link_libraries(server04 wsock32 ws2_32)
|
target_link_libraries(server04 wsock32 ws2_32)
|
||||||
|
add_executable(server05 server05.c server05.h)
|
||||||
|
target_link_libraries(server05 wsock32 ws2_32)
|
||||||
|
|||||||
26
server05.c
Normal file
26
server05.c
Normal 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;
|
||||||
|
}
|
||||||
12
server05.h
Normal file
12
server05.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// Created by Ajurna on 30/07/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SERVER05_H
|
||||||
|
#define SERVER05_H
|
||||||
|
|
||||||
|
#endif //SERVER05_H
|
||||||
|
|
||||||
|
typedef struct HandleArgs {
|
||||||
|
|
||||||
|
}handle_args_t;
|
||||||
Reference in New Issue
Block a user