Start doing TCP networking

This commit is contained in:
2026-04-15 21:38:30 +02:00
parent 258ca9474f
commit d631eb190d
10 changed files with 190 additions and 54 deletions

View File

@@ -0,0 +1,29 @@
#ifndef TCPCLIENT_H
#define TCPCLIENT_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <stdint.h>
#include <dynarr.h>
#define MTU 1500
struct tcp_connection_t {
int clientFd;
struct sockaddr_in clientAddr;
uint32_t clientId;
unsigned char dataBuf[MTU];
ssize_t dataBufLen;
void (*on_data)(struct tcp_connection_t* client);
void (*on_disconnect)(struct tcp_connection_t* client);
pthread_t clientThread;
};
typedef struct tcp_connection_t tcp_connection_t;
#endif