diff options
| author | cashmere <cashmere@autistici.org> | 2026-06-22 20:10:53 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-06-22 20:10:53 +0200 |
| commit | d6eee110abe771c3586d8dc63fc8191c1c39474a (patch) | |
| tree | 746f1af6986f711e5a52e66a1bf4c19d70a2b804 | |
| parent | 52228bb5cb9fe79260e4bcab404390e9fec7b7ee (diff) | |
| download | telnet-d6eee110abe771c3586d8dc63fc8191c1c39474a.tar.gz | |
src/main.c: better close conn and clean up
| -rw-r--r-- | src/main.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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++) { |
