select alters the readfds
you pass in to it. You'll have to provide the file descriptors you want to watch for events each time you call select. e.g.
while(rv != 0) {
FD_ZERO(&readfds);
FD_SET(mySocket, &readfds);
FD_SET(STDIN, &readfds);
rv = select(n, &readfds, NULL, NULL, &tv);