]> Nishi Git Mirror - mokou.git/commitdiff
wip
authorNishi <nishi@nishi.boats>
Sat, 7 Sep 2024 09:25:26 +0000 (09:25 +0000)
committerNishi <nishi@nishi.boats>
Sat, 7 Sep 2024 09:25:26 +0000 (09:25 +0000)
git-svn-id: file:///raid/svn-personal/mokou/trunk@9 35d6bad2-6c5c-c749-ada2-a2c82cb3bd79

Mokou/server.c

index 5569660200fe0e58068d1872e075adf904719f1c..c0c0b97385f83dfa8151deb2e227971a4b493e88 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <poll.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -52,8 +53,12 @@ void mk_server_loop(void){
        cbuf[1] = 0;
        char* str = malloc(1);
        str[0] = 0;
+       struct pollfd pollfds[16 + 1];
+       pollfds[0].fd = server;
+       pollfds[0].events = POLLIN | POLLPRI;
        while(1){
                mk_log("Waiting for the connection");
+               int r = poll(pollfds, 16 + 1, 5000);
                int cli = accept(server, (struct sockaddr*)&cun, &socklen);
                send(cli, ver, strlen(ver), 0);
                while(1){