diff options
| -rw-r--r-- | src/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -26,10 +26,16 @@ int main() { perror("could not listen"); return 1; } + struct pollfd fds[256]; + fds[0].fd = sfd; /* socket file descriptor */ + fds[0].events = POLLIN; /* data to read */ + nfds_t nfds = 1; /* non file descriptor. something with timeout */ while (1) { - int conn = accept(sfd, NULL, NULL); - if (conn == -1) { - perror("could not accept connection"); + /* we start the polling here */ + int ready = + poll(fds, nfds, -1); /* poll to accept many conn simultaneously */ + if (ready == -1) { + perror("could not run poll"); return 1; } char buf[1024]; |
