Prechádzať zdrojové kódy

fix servers does not accept new clients after waiting 10 seconds

Kolja Strohm 1 rok pred
rodič
commit
3bf53fa54f
1 zmenil súbory, kde vykonal 8 pridanie a 8 odobranie
  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;
     }