Created
September 18, 2016 00:48
-
-
Save katlogic/82fa650b8d4196c26e18ca0ebefa77d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/epoll.h> | |
#include <sys/socket.h> | |
#include <stdio.h> | |
int main() | |
{ | |
struct epoll_event ev = { | |
.data.fd = 1 | |
}; | |
int efd = epoll_create(1); | |
ev.events = EPOLLIN|EPOLLET; | |
epoll_ctl(efd, EPOLL_CTL_ADD, 1, &ev); | |
while (1) { | |
struct epoll_event ee; | |
char buf[512]; | |
epoll_wait(efd,&ee,1,-1); | |
int n = recv(1,buf,512,MSG_PEEK|MSG_DONTWAIT); | |
fprintf(stderr,"%d bytes pending\n", n); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment