Added client, fixed typo

This commit is contained in:
Nikita Tyukalov, ASUS, Linux
2026-03-27 00:44:50 +03:00
parent 93c83dc40f
commit 2b870aec34
5 changed files with 197 additions and 3 deletions

17
main.c
View File

@@ -9,8 +9,9 @@
#include <sys/epoll.h>
#include <sys/signalfd.h>
#include "event_loop.h"
#include "client.h"
#include "connection.h"
#include "event_loop.h"
#include "server.h"
#include "utils.h"
@@ -184,6 +185,10 @@ static void on_fd_event(int fd, uint32_t events) {
else if (connection_is_socket_managed(fd)) {
connection_event(fd, events);
}
// Client event
else if (client_event(fd, events)) {
// nothing here
}
else {
fprintf(stderr, "[!] Event has happened on an unknown file descriptor\n");
}
@@ -209,6 +214,13 @@ int main(int argc, char **argv) {
return 1;
}
}
else {
if (!client_init()) {
signals_deinit();
loop_deinit();
return 1;
}
}
// Loop
while (_to_work) {
if (!loop_wait()) {
@@ -221,6 +233,9 @@ int main(int argc, char **argv) {
if (_is_server) {
server_close();
}
else {
client_deinit();
}
connection_cleanup();
signals_deinit();
loop_deinit();