FD_ZERO(&rfds); FD_ZERO(&wfds); if (rd) //TRUE FD_SET(*s,&rfds); //添加要测试的描述字 if (wr) //FALSE FD_SET(*s,&wfds); tv.tv_sec=timems/1000; //second tv.tv_usec=timems%1000; //ms for (;;) //如果errno==EINTR,反复测试缓冲区的可读性 switch(select((*s)+1,&r...
fd_set rfds, wfds; #ifdef _WIN32 TIMEVAL tv; #else struct timeval tv; #endif /*_WIN32*/ FD_ZERO(&rfds); FD_ZERO(&wfds); if(rd) //TRUE FD_SET(*s, &rfds); //添加要测试的描述字 if(wr) FD_SET(*s, &wfds); tv.tv_sec = timems/1000; //seconds tv.tv_usec = timems...
FD_SET(*s,&rfds); //添加要测试的描述字 if (wr) //FALSE FD_SET(*s,&wfds); tv.tv_sec=timems/1000; //second tv.tv_usec=timems00; //ms for (;;) //如果errno==EINTR,反复测试缓冲区的可读性 switch(select((*s)+1,&rfds,&wfds,NULL, (timems==TIME_INFINITE?NULL:&tv))) //...
fd_set rfds, wfds; #ifdef _WIN32 TIMEVAL tv; #else struct timeval tv; #endif /*_WIN32*/ FD_ZERO(&rfds); FD_ZERO(&wfds); if(rd) //TRUE FD_SET(*s, &rfds); //添加要测试的描述字 if(wr) FD_SET(*s, &wfds); tv.tv_sec = timems/1000; //seconds tv.tv_usec = timems...
fd_set rfds,wfds; #ifdef _WIN32 TIM tv; #else struct tim tv; #endif FD_ZERO(&rfds); FD_ZERO(&wfds); if (rd) //TRUE FD_SET(*s,&rfds); //添加要测试的描述字 if (wr) //FALSE FD_SET(*s,&wfds); tv.tv_sec=timems/1000; //second ...
fd_set rfds,wfds; #ifdef _WIN32 TIM tv; #else struct tim tv; #endif FD_ZERO(&rfds); FD_ZERO(&wfds); if (rd) //TRUE FD_SET(*s,&rfds); //添加要测试的描述字 if (wr) //FALSE FD_SET(*s,&wfds); tv.tv_sec=timems/1000; //second ...
fd_set rfds,wfds; #ifdef _WIN32 TIM tv; #else struct tim tv; #endif FD_ZERO(&rfds); FD_ZERO(&wfds); if (rd) //TRUE FD_SET(*s,&rfds); //添加要测试的描述字 if (wr) //FALSE FD_SET(*s,&wfds); tv.tv_sec=timems/1000; //second ...
void FD_SET(int fd, fd_set *set);将标准输入(fd=0)加到文件表述符集合rfds中。
#include <stdio.h> #include <stdlib.h> #include <sys/select.h> int main(void) { fd_set rfds; struct timeval tv; int retval; /* Surveiller stdin (fd 0) en attente d'entrées */ FD_ZERO(&rfds); FD_SET(0, &rfds); /* Attendre jusqu'à 5 secondes. */ tv.tv_sec = 5; tv...
#include <stdio.h> #include <stdlib.h> #include <sys/select.h> int main(void) { int retval; fd_set rfds; struct timeval tv; /* Beobachte stdin (fd 0), um zu sehen, wenn es Eingaben gibt. */ FD_ZERO(&rfds); FD_SET(0, &rfds); /* Warte bis zu fünf Sekunden. */ tv....