瀏覽代碼

fix servers does not accept new clients after waiting 10 seconds

Kolja Strohm 1 年之前
父節點
當前提交
3bf53fa54f
共有 1 個文件被更改,包括 8 次插入8 次删除
  1. 8 8
      Network/Server.cpp

+ 8 - 8
Network/Server.cpp

@@ -53,14 +53,14 @@ SKlient* Server::getKlient() // nimmt Klient an
 	sockaddr_in client;
     int len = sizeof(addresse);
     fd_set set;
-    FD_ZERO(&set);   /* clear the set */
-    FD_SET(sock, &set); /* add our file descriptor to the set */
     int rv = 0;
     struct timeval timeout;
-    timeout.tv_sec = 10;
-    timeout.tv_usec = 0;
     while (rv == 0 && sock)
     {
+        FD_ZERO(&set);      /* clear the set */
+        FD_SET(sock, &set); /* add our file descriptor to the set */
+        timeout.tv_sec = 10;
+        timeout.tv_usec = 0;
         rv = select((int)sock + 1, &set, NULL, NULL, &timeout);
         if (rv == -1) return 0;
     }
@@ -430,14 +430,14 @@ SSLSKlient* SSLServer::getKlient()
 	int len = sizeof(addr);
 	struct sockaddr_in addr;
     fd_set set;
-    FD_ZERO(&set);   /* clear the set */
-    FD_SET(s, &set); /* add our file descriptor to the set */
     int rv = 0;
     struct timeval timeout;
-    timeout.tv_sec = 10;
-    timeout.tv_usec = 0;
     while (rv == 0 && s)
     {
+        FD_ZERO(&set);   /* clear the set */
+        FD_SET(s, &set); /* add our file descriptor to the set */
+        timeout.tv_sec = 10;
+        timeout.tv_usec = 0;
         rv = select((int)s + 1, &set, NULL, NULL, &timeout);
         if (rv == -1) return 0;
     }