poll实例
来源:互联网 发布:程序员薪资调查 编辑:程序博客网 时间:2024/05/22 15:48
#include <stdio.h>
#include <unistd.h>
#include <sys/poll.h>
#define TIMEOUT 5 /* poll timeout, in seconds */
int main (void)
{
struct pollfd fds[2];
int ret;
/* watch stdin for input */
fds[0].fd = STDIN_FILENO;
fds[0].events = POLLIN;
/* watch stdout for ability to write (almost always true) */
fds[1].fd = STDOUT_FILENO;
fds[1].events = POLLOUT;
/* All set, block! */
ret = poll (fds, 2, TIMEOUT * 1000);
if (ret == -1) {
perror ("poll");
return 1;
}
if (!ret) {
printf ("%d seconds elapsed.\n", TIMEOUT);
return 0;
}
if (fds[0].revents & POLLIN)
printf ("stdin is readable\n");
if (fds[1].revents & POLLOUT)
printf ("stdout is writable\n");
return 0;
}
#include <unistd.h>
#include <sys/poll.h>
#define TIMEOUT 5 /* poll timeout, in seconds */
int main (void)
{
struct pollfd fds[2];
int ret;
/* watch stdin for input */
fds[0].fd = STDIN_FILENO;
fds[0].events = POLLIN;
/* watch stdout for ability to write (almost always true) */
fds[1].fd = STDOUT_FILENO;
fds[1].events = POLLOUT;
/* All set, block! */
ret = poll (fds, 2, TIMEOUT * 1000);
if (ret == -1) {
perror ("poll");
return 1;
}
if (!ret) {
printf ("%d seconds elapsed.\n", TIMEOUT);
return 0;
}
if (fds[0].revents & POLLIN)
printf ("stdin is readable\n");
if (fds[1].revents & POLLOUT)
printf ("stdout is writable\n");
return 0;
}
0 0
- poll实例
- poll函数分析实例
- zmq poll实例
- poll()函数实例
- poll机制实例参考
- Linux Poll函数初级实例
- globalfifo驱动实例(poll机制)
- poll接口《来自Linux驱动程序开发实例》
- poll()
- poll
- poll
- poll
- poll()
- poll
- poll
- POLL
- poll
- poll
- 中国女排获得里约奥运会冠军
- dba交接
- HDU 1028 DP 大水题
- Bound Service
- 如何创建github的repository,并和本地仓库关联
- poll实例
- 大数据挖掘笔记2——PageRank
- 【深度学习】卷积层提速Factorized Convolutional Neural Networks
- android中的MVP模式初探
- 一条最长的短信占多少byte?
- 【数据库\Linux】一分钟Linux下MySQL编码问题
- 完美网络
- 1MULTI-DIMENSIONAL SIGNAL PROCESSING AND CIRCUITS FOR ADVANCED ELECTRONICALLY SCANNED ANTENNA ARRAYS
- GYM 100792k King's Rout (拓扑排序+优先队列)