select函数测试
生活随笔
收集整理的這篇文章主要介紹了
select函数测试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/select.h>
int main(int argc,char *argv[])
{
char buf[100] = "";
fd_set rset; //select集合
FD_ZERO(&rset); //將集合清0
FD_SET(0, &rset); //將標準輸入加入到集合中
while(1)
{
#if 0
if(select(1, &rset, NULL, NULL, NULL)>0)
{
printf("please input:");
fflush(stdout);
read(0, buf, 100);
printf("buf=%s\n",buf);
}
#else
printf("please input:");
fflush(stdout);
read(0, buf, 100);
printf("buf=%s\n",buf);
#endif
}
return 0;
}
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/select.h>
int main(int argc,char *argv[])
{
char buf[100] = "";
fd_set rset; //select集合
FD_ZERO(&rset); //將集合清0
FD_SET(0, &rset); //將標準輸入加入到集合中
while(1)
{
#if 0
if(select(1, &rset, NULL, NULL, NULL)>0)
{
printf("please input:");
fflush(stdout);
read(0, buf, 100);
printf("buf=%s\n",buf);
}
#else
printf("please input:");
fflush(stdout);
read(0, buf, 100);
printf("buf=%s\n",buf);
#endif
}
return 0;
}
總結
以上是生活随笔為你收集整理的select函数测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab-画个拱桥和倒影?
- 下一篇: 解决Windows 程序界面闪烁问题的一