- for (i = list_fd + 1; i <= max_fd; i++) {
- if (fd_open[i] == 0) continue;
- if (FD_ISSET(i, &fset)) {
- n--;
- nread = read(fd, buffer, MAXLINE);
+ /* loop on open connections */
+ i = list_fd; /* first socket to look */
+ while (n != 0) { /* loop until active */
+ i++; /* start after listening socket */
+ debug("restano %d socket, fd %d\n", n, fd);
+ if (fd_open[i] == 0) continue; /* closed, go next */
+ if (FD_ISSET(i, &fset)) { /* if active process it*/
+ n--; /* decrease active */
+ debug("dati su fd %d\n", i);
+ nread = read(i, buffer, MAXLINE); /* read operations */