From d6eee110abe771c3586d8dc63fc8191c1c39474a Mon Sep 17 00:00:00 2001 From: cashmere Date: Mon, 22 Jun 2026 20:10:53 +0200 Subject: src/main.c: better close conn and clean up --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.c b/src/main.c index bc91977..f879c54 100644 --- a/src/main.c +++ b/src/main.c @@ -61,6 +61,9 @@ int main() { if (n <= 0) { /* close the connection if client disappeared or disconnected */ close(fds[i].fd); + fds[i] = fds[nfds - 1]; /* move back last slot */ + nfds--; /* size down the current aray */ + i--; } else { /* send every n bytes to the other clients */ for (nfds_t j = 1; j < nfds; j++) { -- cgit v1.3.1