From 03ea2388a79dd428f20542380f22d64500659298 Mon Sep 17 00:00:00 2001 From: cashmere Date: Tue, 30 Jun 2026 22:45:56 +0200 Subject: src/main.c: add struct client --- src/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index bbf26e1..4847bab 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,11 @@ #include #include +struct client { + char nickname[32]; + int has_nickname; +}; + // returns a socket file descriptor. // if connection could not be established, -1 gets returned int establish_connection(struct sockaddr_in addr) { @@ -61,8 +66,7 @@ int process_message(struct pollfd *fds, nfds_t *nfds) { (*nfds)--; /* size down the current array */ i--; return -1; - } - else { + } else { /* send every message bytes to the other clients */ for (nfds_t j = 1; j < *nfds; j++) { if (j != i) { @@ -80,6 +84,7 @@ int main() { addr.sin_family = AF_INET; /* IPv4 */ addr.sin_port = htons(8000); /* Port */ addr.sin_addr.s_addr = INADDR_ANY; /* equals to 0.0.0.0 */ + struct client clients[256]; struct pollfd fds[256]; int sfd = establish_connection(addr); if (sfd == -1) { -- cgit v1.3.1