finished ClientCredential_create

This commit is contained in:
2025-09-28 17:18:17 +05:00
parent 37f38feec7
commit 4fda6ae9e8
15 changed files with 322 additions and 241 deletions

37
src/server/server.c Normal file
View File

@@ -0,0 +1,37 @@
#include "server.h"
#include "db/idb.h"
#include <pthread.h>
typedef struct AcceptedConnection {
Socket sock;
EndpointIPv4 client_end;
} AcceptedConnection;
static void* handle_connection(void* _args);
Result(void) server_run(cstr server_endpoint_str){
Deferral(32);
EndpointIPv4 server_end;
EndpointIPv4_parse(server_endpoint_str, &server_end);
//TODO: add log
try(Socket main_socket, i, socket_open_TCP());
try_void(socket_bind(main_socket, server_end));
try_void(socket_listen(main_socket, 512));
while(true){
AcceptedConnection* args = malloc(sizeof(AcceptedConnection));
try(args->sock, i, socket_accept(main_socket, &args->client_end));
pthread_t conn_thread = {0};
try_stderrcode(pthread_create(&conn_thread, NULL, handle_connection, args));
}
Return RESULT_VOID;
}
static void* handle_connection(void* _args){
Deferral(64);
AcceptedConnection* conn = (AcceptedConnection*)_args;
Defer(free(conn));
Return NULL;
}

5
src/server/server.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#include "network/socket.h"
#include "cryptography/cryptography.h"
Result(void) server_run(cstr server_endpoint_str);