+
+/********************** SERVER SOCKET STUFF **********************/
+HEADER typedef void (*jh_ev_io_ssock_cb)(EV_P_ ev_io *w, int socket);
+static void ev_io_ssock_cb(EV_P_ ev_io *w, int revents) {
+ jh_ev_io_ssock_cb cb = (jh_ev_io_ssock_cb)w->data;
+ if (revents == EV_ERROR) {
+ cb(EV_A_ w, -1);
+ return;
+ }
+ int fd = accept(w->fd, NULL, NULL);
+ if (fd == -1) {
+ fprintf(stderr, "\nLIBJH ERROR: ACCEPT() FAILED - SLEEPING 1s\n");
+ sleep(1);
+ return;
+ }
+ cb(EV_A_ w, fd);
+}
+PUBLIC_FN void jh_ev_io_ssock_init(ev_io *w, jh_ev_io_ssock_cb cb, int fd) {
+ ev_io_init(w, ev_io_ssock_cb, fd, EV_READ);
+ w->data = cb;
+}