you have to re-initialise your read_fds and write_fds after select() returns, because they will be altered by the select() call.