Skip to content

Instantly share code, notes, and snippets.

@arianvp
Created October 3, 2012 18:43
Show Gist options
  • Save arianvp/3828936 to your computer and use it in GitHub Desktop.
Save arianvp/3828936 to your computer and use it in GitHub Desktop.
void accept_cb(EV_P_ ev_io *io, int revents)
{
int client_fd;
socklen_t len;
struct sockaddr_in client_addr;
len = sizeof(client_addr);
client_fd = accept(io->fd, (struct sockaddr *)&client_addr, &len);
fcntl(client_fd, F_SETFL, O_NONBLOCK);
ev_io_init(&ctx->io, read_cb, client_fd, EV_READ);
ev_io_start(EV_A_ &ctx->io);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment