|
|||||
| | |||||
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
int retval=1;
struct timeval tv;
tv.tv_sec = 5;
tv.tv_usec = 0;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(1,&rfds);
if ( (retval = select(2, &rfds, NULL, NULL, &tv)) != 0) {
printf("data is available now");
exit(0);
} else {
exit(0);
}
}
| Leave a Reply |