A poll() example
来源:互联网 发布:成都魔方软件 编辑:程序博客网 时间:2024/05/16 16:10
这是一个简单的poll函数的例子。 用来检测/dev/scullpipe0设备是否可读。
从console中可以看出,当调用了poll后,.poll函数被调用到了。
#include <poll.h>
#include <stdio.h>
#include <fcntl.h>
int main()
{
struct pollfd fda;
int retval;
fda.fd = open("/dev/scullpipe0", O_RDWR);
if (fda.fd < 0)
{
perror("open()");
return -1;
}
fda.events = POLLIN | POLLRDNORM ;
retval = poll(&fda, 1, 5000*10);
if ( retval == 0)
printf("timeout return/n");
else
{
if (fda.revents & POLLRDNORM)
printf("ready to read/n");
if (fda.revents & POLLWRNORM)
printf("ready to write/n");
}
}
- A poll() example
- simple poll echo server example
- Nuttx buttons example: undefined reference to 'poll’
- a simple ajax example
- A simple wxPython example
- A example of Log4c
- A simple DirectShow example
- A example of pointer
- A simple GetOpenFileName example
- A simple makefile example
- A Makefile example
- A simple JNI example
- CGICC:A Tutorial Example
- a simple example rabbitMQ
- A Code Example For SAML
- a example about struts tag
- A Good XSLT Example Site
- coding with a simple example
- Printf()函数简单实现
- 传入一个table,文件名,导出Excel的方法
- 算法分析
- 这半年比较忙,去UK3次,就为了交付项目并且协助测试。
- 调试程序,发现有内存泄漏
- A poll() example
- 如何选型AnyChat SDK/ RTX/华途bigant /V2 Flash/视高等一系类音视频产品
- linux字符界面和图形界面切换方法
- 扒网页~~~
- java 方法参数引用常见错误
- C专家编程 笔记
- sql基础
- 仅供参考视图
- 使用DHCP,为开发板自动分配IP地址