-
-
Save piscisaureus/2319370 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
static ev_io watcher; | |
static void stdin_cb (EV_P_ ev_io *w, int revents) { | |
puts("you can now read some data"); | |
ev_io_stop(&watcher); | |
} | |
int main() { | |
... | |
ev_io_init(&watcher, read_cb, fd, EV_READ); | |
ev_io_start(loop, &watcher); | |
ev_run(); | |
return 0; | |
} | |
---- | |
uv_tcp_t stream; | |
void on_data(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) { | |
puts("we received: "); | |
write(1, buf.base, nread); | |
} | |
int main() { | |
uv_tcp_init(uv_default_loop(), &stream); | |
... | |
uv_read_start(&stream); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment