server03 started

This commit is contained in:
2025-07-30 07:36:07 +01:00
parent da1525252a
commit a14f053132
4 changed files with 355 additions and 1 deletions

42
server03.h Normal file
View File

@@ -0,0 +1,42 @@
//
// Created by Ajurna on 29/07/2025.
//
#ifndef SERVER03_H
#define SERVER03_H
#endif //SERVER03_H
#pragma once
#include <winsock2.h>
typedef struct ClientConnection {
SOCKET client;
char *username;
} client_connection_t;
typedef struct Connections {
size_t size;
size_t len;
client_connection_t *clients;
} connections_t;
typedef struct handleArgs {
int connection;
SOCKET client;
connections_t connections;
} handle_args_t;
void *handle_connection(void *args);
connections_t *connections_create(int size);
void connections_destroy(connections_t *connections);
void connections_append(connections_t *connections, SOCKET client, char *username);
void connections_remove(connections_t *connections, SOCKET client);
char *trim(char *str);
bool username_is_valid(const char *username);
void broadcast(const connections_t *connections, const SOCKET *source, const char *message);