]> git.seodisparate.com - UDPConnection/commitdiff
Fix NetworkTest
authorStephen Seo <seo.disparate@gmail.com>
Wed, 18 Sep 2019 04:56:04 +0000 (13:56 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 18 Sep 2019 04:56:04 +0000 (13:56 +0900)
Allow setting listen addr to "any".

cpp_impl/src/test/UDPC_NetworkTest.cpp

index 554c1e2f04349457721d0252a0fa7caf5b2a65e5..416318c749f0ae312f47a132076cd8f9662dd7ca 100644 (file)
@@ -57,11 +57,31 @@ int main(int argc, char **argv) {
         --argc; ++argv;
     }
 
+    if(!listenAddr) {
+        puts("ERROR: listenAddr was not specified");
+        return 1;
+    } else if(!listenPort) {
+        puts("ERROR: listenPort was not specified");
+        return 1;
+    } else if(isClient && !connectionAddr) {
+        puts("ERROR: connectionAddr was not specified");
+        return 1;
+    } else if(isClient && !connectionPort) {
+        puts("ERROR: connectionPort was not specified");
+        return 1;
+    }
+
+    UDPC_ConnectionId listenId;
     UDPC_ConnectionId connectionId;
+    if(std::strcmp(listenAddr, "any") == 0) {
+        listenId = UDPC_create_id_anyaddr(std::atoi(listenPort));
+    } else {
+        listenId = UDPC_create_id(UDPC_strtoa(listenAddr), std::atoi(listenPort));
+    }
     if(isClient) {
         connectionId = UDPC_create_id(UDPC_strtoa(connectionAddr), std::atoi(connectionPort));
     }
-    auto context = UDPC_init_threaded_update(UDPC_create_id(UDPC_strtoa(listenAddr), std::atoi(listenPort)), isClient ? 1 : 0);
+    auto context = UDPC_init_threaded_update(listenId, isClient ? 1 : 0);
     if(!context) {
         puts("ERROR: context is NULL");
         return 1;