Why FD_SET/FD_ZERO for select() inside of loop?
I am using the select function for communication between my sockets. I have a while loop and I do - while(!done) { FD_ZERO(&read_flags); FD_ZERO(&write_flags); FD_SET(comm_fd1, &read_flags); FD_SET(comm_fd2, &read_flags); FD_SET(STDIN_FILENO, &read_flags); FD_SET(comm_fd1, &write_flags); FD_SET(comm_fd2, &write_flags); FD_SET(STDIN_FILENO, &write_flags); //call select sel = select(comm_fd1+comm_fd2+1, &read_flags, &write_flags, (fd_set*)0, &waitd); and the same with different variables on the client side. I got this basic technique from a tutorial online and just went with it. Then it hit me -