X-Git-Url: http://git.thejh.net/?p=libjh.git;a=blobdiff_plain;f=net.c;h=a5d5b50ef50e107ea676b2428d50332a064bb813;hp=8fe59802e318cbe7a9ee147604d6ddbb96bdbda0;hb=refs%2Fheads%2Fmaster;hpb=6d9303c441fe1d8b473d24f40421d70058e2d2e5 diff --git a/net.c b/net.c index 8fe5980..a5d5b50 100644 --- a/net.c +++ b/net.c @@ -79,24 +79,3 @@ err_socket: freeaddrinfo(addrs); return EAI_SYSTEM; } - -/********************** 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; -}