added session_id generation

This commit is contained in:
2025-10-31 23:53:43 +05:00
parent a0bcd2560a
commit 60a4542328
3 changed files with 31 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ static void* handle_connection(void* _args);
typedef struct ConnectionHandlerArgs {
Socket accepted_socket;
EndpointIPv4 client_end;
u64 session_id;
} ConnectionHandlerArgs;
Result(void) server_run(cstr server_endpoint_str){
@@ -18,9 +19,12 @@ Result(void) server_run(cstr server_endpoint_str){
try_void(socket_bind(main_socket, server_end));
try_void(socket_listen(main_socket, 512));
u64 session_id = 1;
while(true){
ConnectionHandlerArgs* args = (ConnectionHandlerArgs*)malloc(sizeof(ConnectionHandlerArgs));
try(args->accepted_socket, i, socket_accept(main_socket, &args->client_end));
args->session_id = session_id++;
pthread_t conn_thread = {0};
try_stderrcode(pthread_create(&conn_thread, NULL, handle_connection, args));
}
@@ -31,6 +35,7 @@ Result(void) server_run(cstr server_endpoint_str){
static void* handle_connection(void* _args){
Deferral(64);
//ConnectionHandlerArgs* args = (ConnectionHandlerArgs*)_args;
Defer(free(_args));
// TODO: receive handshake and session key
//ClientConnection conn;