summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index a45a40c..a1825d6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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];