Browse Source

HTTP Uploader: request port 80 first and fallback on 8888 or random on failure

Felix Paul Kühne 12 years ago
parent
commit
570214f103
1 changed files with 10 additions and 3 deletions
  1. 10 3
      AspenProject/VLCHTTPUploaderController.m

+ 10 - 3
AspenProject/VLCHTTPUploaderController.m

@@ -91,18 +91,25 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_VERBOSE; // | HTTP_LOG_FLAG_TRACE
 
         [self.httpServer setDocumentRoot:docRoot];
 
-        [self.httpServer setPort:8888];
+        [self.httpServer setPort:80];
 
         [self.httpServer setConnectionClass:[VLCHTTPConnection class]];
 
         NSError *error = nil;
         if(![self.httpServer start:&error])
         {
+            if (error.code == 13) {
+                DDLogError(@"Port forbidden by OS, trying another one");
+                [self.httpServer setPort:8888];
+                if(![self.httpServer start:&error])
+                    return true;
+            }
+
             /* Address already in Use, take a random one */
             if(error.code == 48) {
-                DDLogError(@"Address already in use, trying another one");
+                DDLogError(@"Port already in use, trying another one");
                 [self.httpServer setPort:0];
-                if([self.httpServer start:&error])
+                if(![self.httpServer start:&error])
                     return true;
             }
             DDLogError(@"Error starting HTTP Server: %@", error);