-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux / Unix 系统编程手册 #62
Labels
Comments
ch63io model
Level triggered & Edge Triggered水平沿触发 和 边缘触发 http://flychao88.iteye.com/blog/2187267
select#include <sys/time.h> /* For portability */
#include <sys/select.h>
void FD_ZERO(fd_set *fdset); // 清空
void FD_SET(int fd, fd_set *fdset); // 增加fd
void FD_CLR(int fd, fd_set *fdset); // 删除fd
int FD_ISSET(int fd, fd_set *fdset); // 判断fd是否在set里
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
// Returns number of ready file descriptors, 0 on timeout, or –1 on error 发现OS X与Linux一个不同, timeout参数, struct timeval包含 long tv_sec & long tv_usec, 秒 & 毫秒
epollheader#include <sys/epoll.h> 函数epoll_createint epoll_create(int size);
epoll_ctlint epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev);
argument evstruct epoll_event {
uint32_t events; /* epoll events (bit mask) */
epoll_data_t data; /* User data */
};
typedef union epoll_data {
void *ptr; /* Pointer to user-defined data */
int fd; /* File descriptor */
uint32_t u32; /* 32-bit integer */
uint64_t u64; /* 64-bit integer */
} epoll_data_t;
epoll_waitint epoll_wait(int epfd, struct epoll_event *evlist, int maxevents, int timeout);
events bit maskstruct epoll_event ev;
ev.events; // <- this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
读书笔记
The text was updated successfully, but these errors were encountered: