> When putting the FD_SET macros in the do-while loop everything works like it should.
Yes, select() is allowed to update the fd_set's (in order to tell you which fd's are ready).
Rather than using FD_SET all the time, you can create a 'master' set using FD_SET, then copy them all at once to a working set using FD_COPY.