How to loop select() to poll for data ad infinitum
问题 #include <stdio.h> #include <unistd.h> #include <sys/time.h> #include <sys/types.h> int main () { char name[20]; fd_set input_set; struct timeval timeout; int ready_for_reading = 0; int read_bytes = 0; /* Empty the FD Set */ FD_ZERO(&input_set ); /* Listen to the input descriptor */ FD_SET(0, &input_set); /* Waiting for some seconds */ timeout.tv_sec = 10; // 10 seconds timeout.tv_usec = 0; // 0 milliseconds /* Invitation for the user to write something */ printf("Enter Username: (in 15