Last active
August 29, 2015 14:13
-
-
Save jalcine/b8b61d5521b15d208243 to your computer and use it in GitHub Desktop.
This file contains 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 <uv.h> | |
#include <stdlib.h> | |
// Thanks learnuv. | |
#define CHECK(r, msg) if (r) { \ | |
sprintf("%s: [%s(%d): %s]\n", msg, uv_err_name((r)), (int) r, uv_strerror((r))); \ | |
exit(1); \ | |
} | |
void we_made_it_to_the_poller(uv_poll_t* hdl, int status, int events) | |
{ | |
CHECK(status, "uv_poll_start"); | |
sprintf("%d", events); | |
} | |
int main(void) | |
{ | |
int r = 0, fd; | |
// Allocate the loop. | |
uv_loop_t* loop = uv_default_loop(); | |
uv_poll_t poll_hdl; | |
fd = open("./test_file_polling_libuv.c", O_RDONLY); | |
r = uv_poll_init(loop, &poll_hdl, fd); | |
CHECK(r, "uv_poll_init"); | |
uv_poll_start(&poll_hdl, UV_READABLE, we_made_it_to_the_poller); | |
uv_run(loop, UV_RUN_DEFAULT); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment