- 论坛徽章:
- 0
|
好像和其他平台的poll用法不同,man手册如下,有用过的兄弟给个例子?
struct pollist {
struct pollfd fds[3];
struct pollmsg msgs[2];
} list;
The structure can then be initialized as follows:
list.fds[0].fd = file_descriptorA;
list.fds[0].events = requested_events;
list.msgs[0].msgid = message_id;
list.msgs[0].events = requested_events;
The rest of the elements in thefdsandmsgsarrays can be initialized the same way.
The poll subroutine can then be called, as follows:
nfds = 3; /* number of pollfd structs */
nmsgs = 2; /* number of pollmsg structs */
timeout = 1000 /* number of milliseconds to timeout */
poll(&list, (nmsgs<<16)|(nfds), 1000); |
|