Implemented basic connection logic

This commit is contained in:
Nikita Tyukalov, ASUS, Linux
2026-03-25 00:25:47 +03:00
parent 7eaf35ea4c
commit 8e90c4c152
6 changed files with 572 additions and 1 deletions

View File

@@ -10,6 +10,9 @@
#include <sys/socket.h>
#include <unistd.h>
#include "connection.h"
#include "utils.h"
/*
* Macros
*/
@@ -24,7 +27,21 @@ static int _fd = -1;
* Private API
*/
bool _accept() {
close(accept(_fd, 0, 0));
int fd = accept(_fd, 0, 0);
if (fd == -1) {
fprintf(stderr, "[!] accept failed: %d\n", errno);
return false;
}
uint32_t id = connection_add(fd);
if (!id) {
close(fd);
fprintf(stderr, "[!] connection_add failed\n");
// no returning false, because it would terminate the app
}
else {
const char* data = "Test data lalalala";
connection_send(id, data, strlen(data));
}
return true;
}