2012-12-07 51 views
0

我有我的套接字连接工作,但服务器已更新到SSL。我打电话给这个方法:GCDASyncSocket SSL不连接

[socket startTLS:nil]; 

bu我仍然无法与服务器建立安全连接。我发起这样的连接:

- (void) initNetworkCommunication { 

    dispatch_queue_t mainQueue = dispatch_get_main_queue(); 
    socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:mainQueue]; 

    NSError *err = nil; 
    if (![socket connectToHost:@"192.168.2.210" onPort:1333 viaInterface:@"" withTimeout:-1 error:&err]) // Asynchronous! 
    { 
      // If there was an error, it's likely something like "already connected" or "no delegate set" 
     NSLog(@"I goofed: %@", err); 
    }else 
    { 
     NSLog(@"Connecting..."); 
    } 
    [socket readDataWithTimeout:-1 tag:1]; 

} 

你能帮我吗?

回答

0

我打电话了[插座STARTTLS:无]后使initNetworkCommunication,但它应该是在我们进行连接的那一刻,就像这样:

- (void) initNetworkCommunication { 

    dispatch_queue_t mainQueue = dispatch_get_main_queue(); 
    socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:mainQueue]; 

    NSError *err = nil; 
    if (![socket connectToHost:@"192.168.2.210" onPort:1333 viaInterface:@"" withTimeout:-1 error:&err]) // Asynchronous! 
    { 
      // If there was an error, it's likely something like "already connected" or "no delegate set" 
     NSLog(@"I goofed: %@", err); 
    }else 
    { 
     [socket startTLS:nil]; 
     NSLog(@"Connecting..."); 

     } 
     [socket readDataWithTimeout:-1 tag:1]; 

}